Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #384589

Re: Which newsgroup for json parsing?

From Josef Möllers <josef@invalid.invalid>
Newsgroups comp.lang.c
Subject Re: Which newsgroup for json parsing?
Date 2024-05-16 20:01 +0200
Message-ID <lamvvbFb0g2U1@mid.individual.net> (permalink)
References <la1bjoF2anmU1@mid.individual.net> <v25c4k$1lhfu$1@dont-email.me>

Show all headers | View raw


On 16.05.24 18:27, Mikko wrote:
> On 2024-05-08 13:04:56 +0000, Josef Möllers said:
> 
>> Hi all,
>>
>> I am trying to parse a json string received through MQTT from a 
>> "Shelly Plug S", e.g.
>> {"id":0, "source":"button", "output":true, "apower":0.0, 
>> "voltage":237.9, "current":0.000, 
>> "aenergy":{"total":0.000,"by_minute":[0.000,0.000,0.000],"minute_ts":1715172119},"temperature":{"tC":41.1, "tF":106.0}}
>>
>> I am trying to use libjson-glib but I can't figure out what to use as 
>> the first argument to json_gobject_from_data()!
>> I am also looking at libjson-c but cannot find any examples that could 
>> guide me.
>>
>> Thanks in advance,
> 
> Sometimes it is easier to make a parser than to use an existing one.
> In this case I might try LEX.
> 

Sorry to be nitpicking, but lex is a "lexical analyzer" aka a "scanner", 
it can only recognize tokens, eg the brackets, quotes, identifiers etc, 
but not structures.
"yacc" (or its "bison" equivalent" would be a parser but definitely too 
heavy.

What one could do would be to use LEX to recognize the tokens and the 
write a recursive descent parser in plain C.

But, as I wrote in another posting, I have switched to libjson-c5 and 
the code works fine.

Thanks anyway for helping.

Josef

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Which newsgroup for json parsing? Josef Möllers <josef@invalid.invalid> - 2024-05-08 15:04 +0200
  Re: Which newsgroup for json parsing? Anton Shepelev <anton.txt@g{oogle}mail.com> - 2024-05-08 16:21 +0300
    Re: Which newsgroup for json parsing? Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-05-23 03:03 +0000
  Re: Which newsgroup for json parsing? Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-05-08 15:33 +0100
    Re: Which newsgroup for json parsing? Anton Shepelev <anton.txt@g{oogle}mail.com> - 2024-05-08 19:53 +0300
  Re: Which newsgroup for json parsing? jak <nospam@please.ty> - 2024-05-09 15:18 +0200
  Re: Which newsgroup for json parsing? Josef Möllers <josef@invalid.invalid> - 2024-05-13 11:07 +0200
  Re: Which newsgroup for json parsing? Mikko <mikko.levanto@iki.fi> - 2024-05-16 19:27 +0300
    Re: Which newsgroup for json parsing? Josef Möllers <josef@invalid.invalid> - 2024-05-16 20:01 +0200
      Re: Which newsgroup for json parsing? scott@slp53.sl.home (Scott Lurndal) - 2024-05-16 18:53 +0000
        Re: Which newsgroup for json parsing? bart <bc@freeuk.com> - 2024-05-16 20:21 +0100
          Re: Which newsgroup for json parsing? scott@slp53.sl.home (Scott Lurndal) - 2024-05-16 20:54 +0000
          Re: Which newsgroup for json parsing? Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-05-17 05:24 +0100
            Re: Which newsgroup for json parsing? bart <bc@freeuk.com> - 2024-05-17 15:13 +0100
              Re: XML (was Re: Which newsgroup for json parsing?) Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-05-25 02:53 +0000
            Re: Which newsgroup for json parsing? jak <nospam@please.ty> - 2024-05-17 18:39 +0200
              Re: Which newsgroup for json parsing? Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-05-17 18:07 +0100
      Re: Which newsgroup for json parsing? Mikko <mikko.levanto@iki.fi> - 2024-05-18 16:21 +0300
    Re: Which newsgroup for json parsing? Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-05-23 03:40 +0000
      Re: Which newsgroup for json parsing? scott@slp53.sl.home (Scott Lurndal) - 2024-05-23 17:14 +0000
        Re: Which newsgroup for json parsing? Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-05-23 20:57 +0100

csiph-web