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
14
votes
7 answers

iOS Format String into minutes and seconds

I am receiving a string from the YouTube JSONC api, but the duration is coming as a full number i.e 2321 instead of 23:21 or 2 instead of 0:02. How would I go about fixing this? JSON C EDIT: int duration = [videos valueForKey:@"duration"]; int…
SquiresSquire
  • 2,404
  • 4
  • 23
  • 39
9
votes
3 answers

Memory Leak Using JSON-C

I am new to JSON-C, Please see my sample code and let me know of it will create any memory leak, if yes then how to free JSON-C object. struct json_object *new_obj = NULL; new_obj = json_tokener_parse(strRawJSON); new_obj =…
Madhu S. Kapoor
  • 345
  • 1
  • 5
  • 11
9
votes
2 answers

Append json_object_arrays in C using jsonc library

I am new to the C language. I need to append two json_object arrays created with the json-c library. This is my code: struct json_object *obj1,*array1,*array2,*array3; obj1 = json_object_new_object(); array1 =…
Abdul Manaf
  • 4,933
  • 8
  • 51
  • 95
6
votes
2 answers

What am I missing in compiler options for linking with JSON-C static library?

I am trying to compile the json-c-0.9 test binaries, while statically linking to libjson.a, which I have built and is sitting in /path/to/json-c-0.9/lib: $ gcc -g -v -Wall -std=gnu99 -static -L/path/to/json-c-0.9/lib -ljson test1.c -o test1 …
Alex Reynolds
  • 95,983
  • 54
  • 240
  • 345
5
votes
1 answer

When json-c json_object_to_json_string release the memory

I am using json-c library to send json-object to client.And I notice there is no native function to release the memory which json_object_to_json_string allocate.Does the library release it automaticlly? OR I have to "free(str)" to avoid memory…
riaqn
  • 107
  • 1
  • 8
4
votes
1 answer

Do I have to free json_object returned by json_tokener_parse?

I'm experimenting memory errors in my C application and using valgrind, I see many strange things around the json-c lib. So looking at some infos on the web, I saw this post about json_object_new_object So I have 2 questions to be clear about…
fralbo
  • 2,534
  • 4
  • 41
  • 73
4
votes
1 answer

Undefined symbols for architecture x86_64 with Json-C

Basically it's my first stack overflow question, so I am sorry for any inaccuracies/stupid questions here + I have tried for 3 days to solve my problem using all other answers people gave on similar questions, but either way I don't know Cmake…
BozonK
  • 43
  • 2
  • 4
4
votes
1 answer

How to clean a json object created by "json_object_new_string"?

I have the following code and I want to clean a json object created by json_object_new_string(). #include #include int main() { /*Creating a json object*/ json_object * jobj = json_object_new_object(); /*Creating a…
MOHAMED
  • 41,599
  • 58
  • 163
  • 268
3
votes
1 answer

json-c string with "/" character

When my program saves something in json like this: json_object_object_add(jObj_my, "cats/dogs", json_object_new_double(cats/dogs)); the result in the .json file is: "cats\/dogs" : some_double_number How can i avoid it to print "\/" instead of…
user3717434
  • 215
  • 4
  • 19
3
votes
2 answers

How can I add null values in JSONC?

I am using JSONC library in c to create json. But I can't create null values. How can I create the following json data using JSONC library? {"status" : null }
Kavitha K T
  • 119
  • 8
3
votes
0 answers

Avoid double slashes from json string json-c

I tried to encode a byte array using glib2.0. After I add the encoded data to a json object, after I send the encoded data through pubnub client, I got doble slashed string from json. This is my code : //code for encoding data const guchar…
Abdul Manaf
  • 4,933
  • 8
  • 51
  • 95
3
votes
1 answer

Key names in json-c

I'm using json-c to parse the following JSON string: { "root": { "a": "1", "b": "2", "c": "3" } } And, I have the following C code. The above JSON is stored in the variable, b. json_object *new_obj, *obj1, *obj2; int…
cigarman
  • 635
  • 6
  • 15
2
votes
1 answer

Parse this specific json file

Hello I have never used json-c before and im trying to Parse this json file: { "result": { "schedules": [ { "message": "2 mn", "destination": "La Defense (Grande Arche)" }, { "message":…
LilDev
  • 21
  • 3
2
votes
1 answer

How to use curl in C and parse JSON response

The code below compiles and prints the response. My question is: being the response a string which represents an object, how can I cast "res" into a string or directly into a JSON object? #include #include #include…
Andrés Sanchez
  • 99
  • 1
  • 10
2
votes
1 answer

Can json_object_object_add replace existing entries?

Json-C has this clumsy and poorly-documented reference counting which is giving us problems. In particular, we have an object containing children, and want to replace a particular child with json_object_object_add(parent, "child name",…
MSalters
  • 173,980
  • 10
  • 155
  • 350
1
2 3 4 5 6