parsing json data (packing json file to c file)

85 views
Skip to first unread message

Vinay Kumar

unread,
Sep 2, 2022, 1:50:41 AM9/2/22
to Jansson users
iam completely new to coding & jsoncpp coding
i have a simple json code

"//string": { "prefix": "str", "body": [ "//String", "// C++ program to demonstrate working of raw string literal", "#include <iostream>", "using namespace std;", "", "// Driver Code", "int main()", "{", "    // A Normal string", "    string string1 = \"Geeks.\\nFor.\\nGeeks.\\n\";", "", "    // A Raw string", "    string string2 = R\"(Geeks.\\nFor.\\nGeeks.\\n)\";", "", "    cout << string1 << endl;", "", "    cout << string2 << endl;", "", "    return 0;", "}", "", "" ], "description": "//string" }

need to parse this .json into .c file using parse.

looking for your help @petri

Graeme Smecher

unread,
Sep 9, 2022, 4:32:42 PM9/9/22
to jansso...@googlegroups.com
Hi Kumar,

I see your e-mail hasn't been responded to yet.

Are you asking a question about jsoncpp? If so - this is a Jansson group
and we will be unable to help you here.

best,
Graeme
> --
> --
> Jansson users mailing list
> jansso...@googlegroups.com
> http://groups.google.com/group/jansson-users
> <http://groups.google.com/group/jansson-users>
> ---
> You received this message because you are subscribed to the Google
> Groups "Jansson users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to jansson-user...@googlegroups.com
> <mailto:jansson-user...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jansson-users/22fb0438-809b-4d85-a31d-222bf83f672en%40googlegroups.com
> <https://groups.google.com/d/msgid/jansson-users/22fb0438-809b-4d85-a31d-222bf83f672en%40googlegroups.com?utm_medium=email&utm_source=footer>.

Vinay L

unread,
Sep 12, 2022, 12:48:21 AM9/12/22
to jansso...@googlegroups.com
Hi Greame,

I am looking for Jansson code only, I need  json code to be parsed  to cpp code format.
Please help me with this.
as mentioned in mail,
I have a 'c program' in json format and I need to parse and change that code to actual c code.

Thanking in advance


Best regards
Vinay


To unsubscribe from this group and stop receiving emails from it, send an email to jansson-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jansson-users/76289feb-e1cb-c307-cec4-2492f9e75a57%40gmail.com.

Graeme Smecher

unread,
Sep 12, 2022, 12:09:36 PM9/12/22
to jansso...@googlegroups.com
Hi Vinay,

It looks like you have a JSON encoding of a C++ program (aside: why?)
and you wish to convert this program into source code using another C or
C++ program.

Generally speaking, it's best for you to try writing some code yourself
and contact this list when you run into specific problems you need help
with. Otherwise, it's hard to know where to start.

best,
Graeme

On 2022-09-11 21:48, Vinay L wrote:
> Hi Greame,
>
> I am looking for Jansson code only, I need  json code to be parsed  to
> cpp code format.
> Please help me with this.
> as mentioned in mail,
> I have a 'c program' in json format and I need to parse and change that
> code to actual c code.
>
> Thanking in advance
>
>
> Best regards
> Vinay
>
>
> On Sat, 10 Sept 2022 at 02:02, Graeme Smecher <gsme...@gmail.com
> <mailto:jansso...@googlegroups.com>
> > http://groups.google.com/group/jansson-users
> <http://groups.google.com/group/jansson-users>
> > <http://groups.google.com/group/jansson-users
> <http://groups.google.com/group/jansson-users>>
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Jansson users" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to jansson-user...@googlegroups.com
> <mailto:jansson-users%2Bunsu...@googlegroups.com>
> > <mailto:jansson-user...@googlegroups.com
> <mailto:jansson-users%2Bunsu...@googlegroups.com>>.
> <https://groups.google.com/d/msgid/jansson-users/22fb0438-809b-4d85-a31d-222bf83f672en%40googlegroups.com?utm_medium=email&utm_source=footer
> jansso...@googlegroups.com <mailto:jansso...@googlegroups.com>
> http://groups.google.com/group/jansson-users
> <http://groups.google.com/group/jansson-users>
> ---
> You received this message because you are subscribed to the Google
> Groups "Jansson users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to jansson-user...@googlegroups.com
> <mailto:jansson-users%2Bunsu...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jansson-users/76289feb-e1cb-c307-cec4-2492f9e75a57%40gmail.com
> <https://groups.google.com/d/msgid/jansson-users/76289feb-e1cb-c307-cec4-2492f9e75a57%40gmail.com>.
>
> --
> --
> Jansson users mailing list
> jansso...@googlegroups.com
> http://groups.google.com/group/jansson-users
> <http://groups.google.com/group/jansson-users>
> ---
> You received this message because you are subscribed to the Google
> Groups "Jansson users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to jansson-user...@googlegroups.com
> <mailto:jansson-user...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jansson-users/CABZFAyoJRNT7M-6RWOv6yVCmjw3-rTcApq8_wYzcYTEVNtfrVQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/jansson-users/CABZFAyoJRNT7M-6RWOv6yVCmjw3-rTcApq8_wYzcYTEVNtfrVQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Vinay L

unread,
Sep 13, 2022, 1:00:31 AM9/13/22
to jansso...@googlegroups.com
Hi Greame,

After some research & study on Jansson & detailed study from website : https://jansson.readthedocs.io/en/latest/tutorial.html.

I have parsed the json encoded c program code.

Now what i am looking for is, can we pack the generated 'c program code' back to json code format using jansson ?.
If yes, then can I know how?

To unsubscribe from this group and stop receiving emails from it, send an email to jansson-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jansson-users/a487bd46-bbab-68dc-2034-04989c7ae5cf%40gmail.com.

Basile Starynkevitch

unread,
Sep 13, 2022, 4:29:34 AM9/13/22
to jansso...@googlegroups.com


On 9/13/22 07:00, Vinay L wrote:
Hi Greame,

After some research & study on Jansson & detailed study from website : https://jansson.readthedocs.io/en/latest/tutorial.html.

I have parsed the json encoded c program code.


Why are you doing so?


Now what i am looking for is, can we pack the generated 'c program code' back to json code format using jansson ?.
If yes, then can I know how?



Why do you need to do so?


Did you consider:


generating C or C++ code, as a set of textual files? An example (rather useless, except to show that on Linux you can have many plugins) is https://github.com/bstarynk/misc-basile/blob/master/manydl.c

A book explaining the interest of generating a lot of C plugins/modules on Linux is Jacques Pitrat last book:

Artificial Beings: The Conscience of a Conscious Machine

https://www.amazon.fr/Artificial-Beings-Conscience-Conscious-Machine/dp/1848211015

ISBN-13 ‏ : ‎ 978-1848211018


writing some GCC plugin (see https://gcc.gnu.org/ and https://gcc.gnu.org/onlinedocs/gccint/Plugins.html ....) and use its GIMPLE representation (see https://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html ....)


Thanks

-- 
Basile Starynkevitch                  <bas...@starynkevitch.net>
(only mine opinions / les opinions sont miennes uniquement)
92340 Bourg-la-Reine, France
web page: starynkevitch.net/Basile/

Reply all
Reply to author
Forward
0 new messages