I've got a program that outputs data in json format. I'm wanting to read from that program and parse the json data, then add my own variables to the json object. I'm lost on how to parse the data once i've done the file open and read. any suggestions on how to parse through it, maybe assign a name to the newly created object?
I'm on linux, writing in C.
#include <stdio.h>
#include <json/json.h>
int main(int argc, char ** argv){
printf("Getting Location Data from pipe: \n");
FILE *in;
extern FILE *popen();
char gps_stream[4096];
if(!(in = popen("gpspipe -w", "r"))){
printf("Cant do it!\n");
}
while(fgets(gps_stream, sizeof(gps_stream), in)!=NULL){
json_object * jobj = json_tokener_parse(gps_stream);
}
pclose(in);
}