I have created the jobj
by using json-c library successfully with the json_object_to_json_string(jobj)
where jobj
hold the data which is in json format.
I am able to print jobj
on the console by using printf
:
printf ("%s",json_object_to_json_string(jobj));
Now I need write the jobj
data to file in "C" language as jobj
we declared as json_object * jobj = json_object_new_object();
Request to provide the info on the above i.e. writing the jobj
to a file (fwrite).
Below is the example code snipet https://linuxprograms.wordpress.com/2010/08/19/json_object_new_array/
Below is the code snipet
static void prepared_line_file(char* line)
{
FILE* fptr;
fptr = fopen("/home/ubuntu/Desktop/sample.json", "a")
fwrite(line,sizeof(char),strlen(line),logfile);
}
main()
{
json_object_object_add(jobj,"USER", jarray);
prepared_line_file(jobj);
}
am i missing anything?