Questions tagged [jansson]

questions about the Jansson JSON library

Jansson is a JSON library for C. See: https://github.com/akheron/jansson

35 questions
5
votes
1 answer

How do I add a library dependency in an Azure Sphere Visual Studio Project?

I am building an Azure Sphere C application, starting from the HTTPS_Curl_Easy sample project. I need json parsing, so I downloaded the Jansson library code. The project that Jansson generates when using Cmake wouldn't add as a reference to my…
Joon
  • 2,127
  • 1
  • 22
  • 40
3
votes
0 answers

Multiline 'values' in json using the Jansson API

Something in here is not allowing '\n' to be interpreted as a newline control character. Can someone help? The output, when printed, seems to print "I want this statement\nto be in newlines,\nbecause I want it\n that way.", AND NOT "I want this…
3
votes
1 answer

File reading in buffer identical methods between C and C++?

I was using the Jansson C library to parse some JSON file and using the method used in the sample file I tried to parse it using C-like code: FILE *f = fopen(json_path.c_str(), "r"); fseek(f, 0L, SEEK_END); long size = ftell(f); fseek(f, 0L,…
baptiste
  • 1,107
  • 2
  • 15
  • 30
3
votes
4 answers

Why is Jansson's is_json_object() failing to recognize my JSON string?

I am new to C++ and cannot figure out how to strip some miscellaneous data from a string and then parse it as JSON. I've ended up using the most documented JSON parser I could find - jansson. It seems excellent, although I'm stuck at the first…
simonmorley
  • 2,810
  • 4
  • 30
  • 61
2
votes
0 answers

How to send json data using librdkafka?

I'm trying to send a json payload using librdkafka c api. What I'm trying to do now is #include #include #include #include #include #include typedef struct my_data { …
kovac
  • 4,945
  • 9
  • 47
  • 90
2
votes
2 answers

How to get the double free error on run time in my c++ code

I am using the Jansson library in my c++ code. In the library when any Jansson variable is created, the variable should be freed to release the reference and I am using the 'json_decref(json_t *json)' method to release. But sometimes it causes the…
SayMyName
  • 461
  • 5
  • 17
2
votes
0 answers

Format JSON text using jansson in C

So I'm trying to format text in a desired fashion using the received JSON string in server side. My code is using jansson library to parse JSON. Here is the input JSON string (will be received from client): {"system": {"hmiSettings": {"wifi":…
2
votes
1 answer

jansson library for cross compilation with arm-linux-gnueabi-gcc

I have application that uses jansson library. I want to change our architecture to ARM board. I was searching for how to compile / or source for ARM jansson library, but without any succeed. Does someone has any idea how to tailor the existing…
Hunry3rd
  • 51
  • 1
  • 1
  • 8
1
vote
1 answer

using jansson api's create json file write data into file but i need new line for very key

Output: {"PSM": {"LinkName": "ath6", "LinkType": "WiFi", "PriorityTag": 1, "Pvid": 106}, "SYSCFG": {"LinkName": "ath6", "LinkType": "WiFi", "PriorityTag": 0, "Pvid": 107}, "rbus_event": {"LinkName": "ath6", "LinkType": "WiFi", "PriorityTag": 0,…
charan
  • 11
  • 1
1
vote
1 answer

How to set precision for json_real while doing json_dump using jansson library

If a double value of 8.13 is passed into json_real and dump the json i see that its printing 8.1300000000000008, Is there any way to get 8.13 or 8.13000000000000000 exactly in C? double test = 8.13; json_t* msgtest = json_object(); …
Scarlet
  • 131
  • 7
1
vote
1 answer

C : jansson json_decref - segmentation fault

I have a for loop and while iterating the loop, if the index is even index the json object has to be freed and again a new object has to be constructed and again the process has to be repeated. For the same, using the below script, #include…
Mahamutha M
  • 1,235
  • 1
  • 8
  • 24
1
vote
1 answer

jansson-change json value in file

I have a json file. And, the file is successfully loaded. but, i would like to change the value such as below and save the json file with the modification. But, the value is not changed and saved at all. How could i do? from…
nayang
  • 157
  • 1
  • 14
1
vote
1 answer

what is the proper way of free memory in creating json request from jansson libary?

i am using janson library to send json body as rest request's , i have notice that i am doing it in this way : json_t *json_body = json_object(); char sentString[100]; char sentStringSecond[100]; .. json_object_set_new(json_body, "sentString",…
Omer Anisfeld
  • 1,236
  • 12
  • 28
0
votes
0 answers

Cannot compile static despite specifying -DBUILD_SHARED_LIBS=OFF

I have the following CMakeLists.txt cmake_minimum_required(VERSION 3.16) project(LSODrinkServer VERSION 0.1 LANGUAGES C) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") list(APPEND CMAKE_MODULE_PATH…
0
votes
1 answer

How to use json_incref, json_decref, and json_get to look at a piece of a json file?

I have been struggling to understand the proper use of json_decref and json_incref in combination with the json_get functions to isolate and manipulate a small piece of a larger json file without keeping the whole thing in memory. This question is…
user2309840
  • 101
  • 2
1
2 3