How Can I Convert Struct?

How do you convert a C struct to JSON using the JSON-C library?

Venkata Narasinga Rao Koppu at Quora Visit the source

Was this solution helpful to you?

Other answers

Having come across the same issue, i wrote a library that helps with this problem. https://github.com/jamie-pate/jstruct . You can annotate existing c structures, and a python script generates meta-data c headers based on the annotations. The library reads the metadata to import/export c structures to json strings and back. A python script takes care of parsing the annotated header and generating new headers and metadata initializers. The jstruct library uses https://github.com/json-c/json-c  internally.I have also noticed https://github.com/marel-keytech/jsoncc but that was after writing the entire thing. (and info on that project's page is sparse)

Jamie Pate

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.