0

How do I get information from a JSON file in C? For example the following code in Python

open('simfin.json').read()
var = json.loads(open('simfin.json').read())
var = var["var"]

Gets the value that I gave to a variable and then stores it in var. How do I do it in C, then write it to the .json file, preferably using Jansson?

Here's my .json file:

{
    "whenaddrm": "01/01/1970 00:00",
    "var": 0,
    "moneyaddrm": 0
}
lost_in_the_source
  • 10,998
  • 9
  • 46
  • 75
  • The tutorial of the jansson library looks useful at first glance. Have you tried with json_loads and then using json_object_get ? – StefanW Feb 10 '16 at 22:33
  • there are so many json libraries available for C, just choose one and go with it, read the docs. For example you could use https://github.com/json-c/json-c – rfreytag Feb 10 '16 at 22:40

0 Answers0