Source Code File 10-01_jsonopen
10-01_jsonopen.c
#include <stdio.h> #include <stdlib.h> #include <json-c/json.h> int main() { const char filename[] = "sample.json"; json_object *jdata; jdata = json_object_from_file(filename); if( jdata==NULL ) { fprintf(stderr,"Unable to process %s\n",filename); exit(1); } printf("File %s read successfully\n",filename); return(0); }
Output
Upon success:
File sample.json read successfully
Upon failure:
Unable to process sample.jgon
Notes
* The file sample.json is included with the files available for this book.
Copyright © 1997-2024 by QPBC.
All rights reserved