Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #143906
| Subject | Re: Static JSON parser for embedded |
|---|---|
| Newsgroups | comp.lang.c |
| References | (3 earlier) <sdzDE.389927$v12.254932@fx29.am4> <qbmgvk$n78$1@dont-email.me> <XIBDE.241096$SH1.40745@fx03.am4> <1NFDE.380734$II6.269803@fx07.am4> <qbnbtj$lo8$1@dont-email.me> |
| From | Bart <bc@freeuk.com> |
| Message-ID | <NhIDE.542225$sX.225513@fx31.am4> (permalink) |
| Organization | virginmedia.com |
| Date | 2019-05-18 01:25 +0100 |
On 17/05/2019 23:17, pozz wrote: > Il 17/05/2019 23:33, Bart ha scritto: >> On 17/05/2019 17:56, Bart wrote: >>> On 17/05/2019 15:37, pozz wrote: >> >>>> Consider a big JSON file stored on an external I2C or SPI memory >>>> (not on the same bus of the processor). The application could read >>>> 128-bytes parts and feed the parser, saving a lot of memory. >> >>> I think I'll have a go at doing this, although I don't know if I'll >>> come up with anything that will be of any use to you. >> >> I feel that doing a fully working solution in C (to convert C code >> declaring a struct, to C source that can parse that struct) would be >> too much work to complete. But I will continue to play with it. >> >> At least I now have my own JSON parser >> (https://github.com/sal55/qx/blob/master/readjson.b, not in C, which >> converts a json file to a 'dict' dynamic data structure) > > Are you sure starting from JSON file is a good choice? I was thinking to > start from C struct definition (in pure C code or something else). > > Otherwise you should have a JSON file with populated keys and values. Well, that seemed to work. I modified my test reader so that it would fill in the values of a struct: https://github.com/sal55/qx/blob/master/parsejson.b (Dynamic language, not C, not Python.) Here I've manually hard-coded the table for your example struct (lines 64 to 67). The struct definition does exist, or a version of the C one (lines 19 to 23), but here it's just for testing - to more easily set up a dummy destination of the right size, and to easily print the result. Otherwise it's not needed. The struct printed from this program using that table, as populated from the JSON example in your OP: (12345, John, (-3,7,8,0,0,0,0,0)) I won't take this further as there are lots of other complications (like nested arrays, nested structs, optional fields and extra flag fields); all sorts of other details I don't know about and which would come up, and I don't know the overall context (how even does it decide which struct a bit of incoming JSON will describe). But it shows that a 'dynamic' parser - hard-coded program, but tables somehow generated from C structs, could work, even in C. (A C version would just have taken longer to try out.) >> So some ideas anyway if you (the OP) are thinking of a DIY solution. > > I'm sorry, it's very difficult for me. Maybe you should make it into a contest like someone suggested. People here quite like writing code. But the task needs to be smaller and more well-defined.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-05-17 09:20 +0200
Re: Static JSON parser for embedded Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-05-17 08:48 +0000
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-05-17 11:06 +0200
Re: Static JSON parser for embedded Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-05-17 11:22 +0000
Re: Static JSON parser for embedded Thiago Adams <thiago.adams@gmail.com> - 2019-05-17 04:40 -0700
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-05-17 14:10 +0200
Re: Static JSON parser for embedded Thiago Adams <thiago.adams@gmail.com> - 2019-05-17 05:18 -0700
Re: Static JSON parser for embedded Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-05-18 18:18 +0000
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-05-17 14:10 +0200
Re: Static JSON parser for embedded Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-05-18 18:22 +0000
Re: Static JSON parser for embedded Bart <bc@freeuk.com> - 2019-05-17 11:39 +0100
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-05-17 13:19 +0200
Re: Static JSON parser for embedded Thiago Adams <thiago.adams@gmail.com> - 2019-05-17 05:09 -0700
Re: Static JSON parser for embedded Thiago Adams <thiago.adams@gmail.com> - 2019-05-17 05:15 -0700
Re: Static JSON parser for embedded Bart <bc@freeuk.com> - 2019-05-17 15:06 +0100
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-05-17 16:37 +0200
Re: Static JSON parser for embedded Bart <bc@freeuk.com> - 2019-05-17 17:56 +0100
Re: Static JSON parser for embedded "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-05-17 10:21 -0700
Re: Static JSON parser for embedded Bart <bc@freeuk.com> - 2019-05-17 18:43 +0100
Re: Static JSON parser for embedded Thiago Adams <thiago.adams@gmail.com> - 2019-05-17 10:58 -0700
Re: Static JSON parser for embedded "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-05-17 11:16 -0700
Re: Static JSON parser for embedded Bart <bc@freeuk.com> - 2019-05-17 19:43 +0100
Re: Static JSON parser for embedded "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-05-17 11:57 -0700
Re: Static JSON parser for embedded Bart <bc@freeuk.com> - 2019-05-17 20:11 +0100
Re: Static JSON parser for embedded "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-05-17 12:22 -0700
Re: Static JSON parser for embedded Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-05-17 21:33 +0100
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-05-18 00:11 +0200
Re: Static JSON parser for embedded Bart <bc@freeuk.com> - 2019-05-17 22:33 +0100
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-05-18 00:17 +0200
Re: Static JSON parser for embedded Bart <bc@freeuk.com> - 2019-05-18 01:25 +0100
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-05-17 23:43 +0200
Re: Static JSON parser for embedded Thiago Adams <thiago.adams@gmail.com> - 2019-05-17 04:38 -0700
Re: Static JSON parser for embedded "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-05-17 07:38 -0700
Re: Static JSON parser for embedded Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2019-05-17 08:05 -0700
Re: Static JSON parser for embedded "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-05-17 08:15 -0700
Re: Static JSON parser for embedded Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2019-05-17 11:53 -0400
Re: Static JSON parser for embedded Ian Collins <ian-news@hotmail.com> - 2019-05-18 15:33 +1200
Re: Static JSON parser for embedded Bart <bc@freeuk.com> - 2019-05-18 11:57 +0100
Re: Static JSON parser for embedded Clifford Heath <no.spam@please.net> - 2019-05-18 17:14 +1000
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-05-18 16:03 +0200
Re: Static JSON parser for embedded Clifford Heath <no.spam@please.net> - 2019-05-19 09:12 +1000
Re: Static JSON parser for embedded Niklas Holsti <niklas.holsti@tidorum.invalid> - 2019-05-19 17:13 +0300
Re: Static JSON parser for embedded Clifford Heath <no.spam@please.net> - 2019-05-20 09:25 +1000
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-06-06 11:12 +0200
Re: Static JSON parser for embedded Clifford Heath <no.spam@please.net> - 2019-06-07 09:11 +1000
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-06-07 08:59 +0200
Re: Static JSON parser for embedded Clifford Heath <no.spam@please.net> - 2019-06-12 09:41 +1000
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-06-05 16:44 +0200
Re: Static JSON parser for embedded Clifford Heath <no.spam@please.net> - 2019-06-06 09:27 +1000
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-06-06 09:50 +0200
Re: Static JSON parser for embedded Clifford Heath <no.spam@please.net> - 2019-06-07 09:08 +1000
Re: Static JSON parser for embedded Clifford Heath <no.spam@please.net> - 2019-06-06 09:48 +1000
Re: Static JSON parser for embedded pozz <pozzugno@gmail.com> - 2019-06-06 09:54 +0200
csiph-web