Questions tagged [json-c]

JSON-C is a C library for parsing and generating JSON. It includes a reference counted model for JSON objects.

For more information: JSON-C - A JSON implementation in C

86 questions
0
votes
0 answers

json-c how remove a string element from a json array?

let's say I have this json-array : "test": { "d": "med", "min": [ "low","med","high"]} now using json-c api I want to remove the high string from the key min. int arrLen=json_object_array_length(test_array_min); int j=0; json_object…
Nizan
  • 1
  • 1
0
votes
1 answer

Use of json_object_put() in C library

I am using the json-c in my C program (not C++). I am getting segfaults from time to time and trying to debug. To be honest, I might not have the full understanding how the library works so I am looking for any advice. This is partially how I am…
Christian
  • 169
  • 8
0
votes
0 answers

Adding object to JSON-C array in loop

I am trying to build a JSON object using the json-c library and I am using the C language. I would like to know the best way to add objects to an array in a loop. What I have: struct json_object * build_array(char *input_buffer) { struct…
spiderwebdev
  • 75
  • 1
  • 8
0
votes
0 answers

import JSONC files into react app and use the properties

I have a app where i would like it to import all my jsonc files and be able to iterate through the objects i the files. Right now i have this function, which imports the files: function importAll(r) { let files = {}; …
Nadia Hansen
  • 697
  • 2
  • 6
  • 16
0
votes
1 answer

Updating a value of key in json-c object

I am trying to create a temporary database using json-c. For that i have created a simple function which return a json object with default value as key:{"value":data} pair and then i am trying to update value of existing signals in database. But…
0
votes
1 answer

Can't free my json object in C (assertion failed)

I've the following JSON object: { "heartbeat": { "status": 0, "tempID": 1210254506, "firmware": "obu-hmi-commsignia", "sync": 1, "upgrade": 0, "log": 0, "fix": 3, "rsu": 1, "numTx": 5813, "numRx": 5685, …
ofstack773
  • 49
  • 5
0
votes
0 answers

Memory leak with json-c in multi-threaded C++ program

I have a memory leak in my program and cannot understand why. My program is multi-threaded and uses json-c and glib. Thread 1 calls the following method every time it receives data over a UDP stream. void foo(state_t *self, const char *data) { …
olivier
  • 1
  • 1
0
votes
1 answer

Youtube API - Querying JSON for a video id loads empty embedded iframe

I put it all here: http://jsfiddle.net/uJ3h7/ But I'll repost the mark-up…
Angel Marino
  • 95
  • 1
  • 9
0
votes
1 answer

There is no json.h in \usr\include\json-c directory ' ../nvme.h:26:10: fatal error: json.h: No such file or directory'

There is no "json.h" in "\usr\include\json-c" directory. Is there an application that I have to install? I have installed "sudo apt-get install libjsoncpp-dev," but it is not working. ubuntu@nvme-cli:~/nvme-cli$ ninja -C .build ninja: Entering…
Hossein
  • 113
  • 1
  • 6
0
votes
1 answer

Constructing json object in C with json-c

I am new to json-c. I am able to create JSON object in the format: {"loglevel":"INFO", "msg":"Info about car", "timestamp":"actual system time"} but I need help in creating the JSON object in the format: {"module":"log","version":1.0,…
0
votes
1 answer

Free memory of all json_objects from root (including root)

I have this code: struct json_object* parsed_json; struct json_object* portInConfig; struct json_object* masterInConfig; struct json_object* mapInConfig; struct json_object* managerPasswdInConfig; struct json_object*…
Haxk20
  • 77
  • 7
0
votes
1 answer

How to loop through keys and values in C using the json-c library?

I'm using json-c to parse json. Is it possible to loop through the keys and values. json_object_object_get_ex() : this function requires prior knowledge what the keys are. What if we don't know the keys and we have to loop through them.
0
votes
1 answer

extracting data from JSON file to a structure in c

This code aim to extract data from a JSON file: [{ "name": "alice", "age": 30, "friends" : ["marc","max" ,"alice"] }, {"name": "john", "age": 25,"friends" : ["fr","mario" ,"Jim"]}] and store the data into a structure so this is the code: static…
ing23
  • 69
  • 1
  • 1
  • 7
0
votes
0 answers

How to use Json-c parser or any other parser in Eclipse for C programming in Windows

I use Eclipse C/C++ developer IDE in Windows 10 I have downloaded json-c parser but I dont know to use it in eclipse for C Programming. I downloaded it from this link https://github.com/json-c/json-c. I have downloaded the Json Editor Plugin from…
Nishith
  • 33
  • 1
  • 7
0
votes
1 answer

Traversing through and modifying a C json string

What's the correct way to traverse and modify a JSON string in C? Specifically, I have a string, body_buf. When printed out print("length: %d\n%.*s\n", body_len, body_len, body_buf); It looks like this: length:…
ajfbiw.s
  • 401
  • 1
  • 8
  • 22