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
2
votes
1 answer

undefined reference to `json_tokener_parse'

all. I'm having trouble using the JSON-C library on an OpenWRT linux distribution. I made a simple program below in order to test it. #include int main() { char * string = "{\"name\" : \"joys of programming\"}"; json_object *…
Garrett
  • 353
  • 7
  • 14
2
votes
2 answers

Parsing deeply nested JSON key using json-c

I'm using the json-c library, and after reviewing the documentation, I couldn't find a way to get at a deeply nested key/value without using a bunch of loops, here's what I've tried: json_object_object_foreach(json_data_obj, key, val) { …
hagope
  • 5,523
  • 7
  • 38
  • 52
2
votes
1 answer

Is the JSON C library thread-safe?

Am using the C JSON library under Ubuntu (json-c/json.h). I need to parse JSON strings on multiple POSIX threads. Am currently using the json_tokener_parse() method - is this multi-thread safe or do I need to use something else? thnx
dbassu
  • 23
  • 3
2
votes
1 answer

Adding JSON-C to existing POSTGIS install

Using EnterpriseDB's GUI installer, I installed Postgres 9.3.5 on my Mac running Mavericks. I selected the option to install spatial components and PostGIS 2.1.3 was installed automatically. After enabling the PostGIS extension, I was able to…
Don
  • 21
  • 3
1
vote
0 answers

JSON-C is there a way to use json_object_object_add to add to the beginning of an object that is already populated?

I am working with JSON-C in C to add to an object. Is there a way to use json_object_object_add to add to an existing object but at the beginning of the object? Example: json_object * jobj = json_object_new_object(); json_object_object_add(jobj,"Key…
spiderwebdev
  • 75
  • 1
  • 8
1
vote
1 answer

Memory leak with json_object_get_string

I am quite new in C, and I am using the json-c library. I am completely sure that the problem I have is with json_object_get_string, because if I don't use it and put a string manually in my structure it works in valgrind without any memory leak. I…
jcarlosweb
  • 846
  • 1
  • 14
  • 30
1
vote
1 answer

json-c: Format new double object type?

I use the json-c lib to create a json-formated string. I have some float values and json-c does some conversion to double which leads to some errors: float nachtmodusfaktor; nachtmodusfaktor =…
Christian
  • 169
  • 8
1
vote
1 answer

How to write the json-c object into a file using C?

I have created the jobj by using json-c library successfully with the json_object_to_json_string(jobj) where jobj hold the data which is in json format. I am able to print jobj on the console by using printf: printf…
1
vote
0 answers

Getting errror When install Postgis in Postgresql 14 from source

I'm trying to install Postgis. I have install prerequisite: Geos 3.5.6 Proj 7.0.0 Jsonc 0.15 gDal 3.0.0 This is logs when Configure Postgis: ./configure --prefix=/opt/postgis --with-pgconfig=/opt/postgresql/bin/pg_config…
quanchinhong
  • 142
  • 3
  • 18
1
vote
1 answer

Using the json-c library to parse a json array

I have the following JSON data returned to me from a server, and I'm unable to figure out how to parse the maneuvers array for the narrative: { "maneuvers": [ { "signs": [], "index": 0, "maneuverNotes":…
duskdusk13
  • 59
  • 1
  • 7
1
vote
2 answers

json_tokener_parse , Segmentation fault

void TestSegFunction(void) { int i = 0; char *str = "\"{\"loop_number\":1}\""; // line 410 char *str = "{\"loop_number\":1}"; // line 411 json_object *pstObj = NULL; json_object *sonPstObj = NULL; pstObj =…
yanzhang.guo
  • 107
  • 2
  • 17
1
vote
1 answer

extract key (not value) from json-c json_object

I am currently playing with libnftables and json-c (C libraries) my aim is to parse nftables rules in json format with json-c library The thing is there, nftables elements (a table for example) look like this: { "table":{ "family":"ip", …
1
vote
1 answer

How to compile C file with Library imports to webassembly file (Emscripten)

I have a simple C program that needs to parse Json data. For that I have imported JSON-C library. My C code is - #include"json.h" #include EMSCRIPTEN_KEEPALIVE int addnumbers(int a, int b) { FILE *fp; char buffer[1024]; …
Yash Gaur
  • 143
  • 2
  • 12
1
vote
1 answer

Copy file in a char[] array crash if newline

I'm reading and parsing a json file; all it works correctly if in the file there aren't new line; here's the code : #include #include #include void parse_json(json_object * jobj); int main(int argc, char*…
DDBE
  • 325
  • 3
  • 13
1
vote
1 answer

libjson-c.so.3 vs libjson-c.so.2 in Ubuntu

I am trying to run a C++ program developed on Ubuntu 18.04. It uses JSON-C shared library. It compiles and runs without any problem on my Ubuntu 18.04 system. However it compiles on a Ubuntu 14.04 system but crash upon running, Reporting following…
Anuradha
  • 63
  • 1
  • 10