Re: Which newsgroup for json parsing?

Liste des GroupesRevenir à l c 
Sujet : Re: Which newsgroup for json parsing?
De : nospam (at) *nospam* please.ty (jak)
Groupes : comp.lang.c
Date : 17. May 2024, 18:39:01
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v28175$29d9i$1@dont-email.me>
References : 1 2 3 4 5 6
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.18.2
Malcolm McLean ha scritto:
On 16/05/2024 20:21, bart wrote:
On 16/05/2024 19:53, Scott Lurndal wrote:
=?UTF-8?Q?Josef_M=C3=B6llers?= <josef@invalid.invalid> writes:
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.
>
I've done full expression parsing and subsequent evaluation with
lex (or flex).  No parser needed.
>
>
You've done 'full expression PARSING', then you say 'No PARSER needed'.
>
A bit contradictory?
>
Clearly parsing IS needed, so either you've used LEX from code that acts as a parser, or it does more than just recognise tokens.
>
Yes.
 I took Ben's advice and completely rewrote my XML parser wirh a formal lexer and recursive descent grammar. It was good idea, even though XML is simple enough to get away with a ad hoc approach. Similarly, with JSON. once you've lexed into identifiers, values, and curly and square btackets, the grammar is so simple that you almost don't notice that you are writing a parser.
   --
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm
 
Don't you think it is overkill to use a compiler of compilers to parse a
Json?  The function I wrote for parse the Json is just 140 code lines in
C, while I found examples with much more bulky with lex & yacc.

Date Sujet#  Auteur
8 May 24 * Which newsgroup for json parsing?29Josef Möllers
8 May 24 +* Re: Which newsgroup for json parsing?2Anton Shepelev
23 May 24 i`- Re: Which newsgroup for json parsing?1Lawrence D'Oliveiro
8 May 24 +* Re: Which newsgroup for json parsing?2Malcolm McLean
8 May 24 i`- Re: Which newsgroup for json parsing?1Anton Shepelev
9 May 24 +- Re: Which newsgroup for json parsing?1jak
13 May 24 +- Re: Which newsgroup for json parsing?1Josef Möllers
16 May 24 `* Re: Which newsgroup for json parsing?22Mikko
16 May 24  +* Re: Which newsgroup for json parsing?19Josef Möllers
16 May 24  i+* Re: Which newsgroup for json parsing?6bart
17 May 24  ii`* Re: Which newsgroup for json parsing?5Malcolm McLean
17 May 24  ii +* Re: Which newsgroup for json parsing?2bart
25 May 24  ii i`- Re: XML (was Re: Which newsgroup for json parsing?)1Lawrence D'Oliveiro
17 May 24  ii `* Re: Which newsgroup for json parsing?2jak
17 May 24  ii  `- Re: Which newsgroup for json parsing?1Malcolm McLean
18 May 24  i`* Re: Which newsgroup for json parsing?12Mikko
27 May 24  i `* Re: Which newsgroup for json parsing?11Josef Möllers
27 May 24  i  `* Re: Which newsgroup for json parsing?10Vir Campestris
28 May 24  i   `* Re: Which newsgroup for json parsing?9Josef Möllers
28 May 24  i    +* Re: Which newsgroup for json parsing?7Michael S
28 May 24  i    i+- Re: Which newsgroup for json parsing?1Josef Möllers
29 May 24  i    i+* Re: Which newsgroup for json parsing?3Malcolm McLean
29 May 24  i    ii`* Re: Which newsgroup for json parsing?2David Brown
30 May 24  i    ii `- Re: Which newsgroup for json parsing?1Malcolm McLean
31 May 24  i    i+- Re: Which newsgroup for json parsing?1Tim Rentsch
5 Aug 24  i    i`- Re: Which newsgroup for json parsing?1Lawrence D'Oliveiro
30 May 24  i    `- Re: Which newsgroup for json parsing?1Vir Campestris
23 May 24  `* Re: Which newsgroup for json parsing?2Lawrence D'Oliveiro
23 May 24   `- Re: Which newsgroup for json parsing?1Malcolm McLean

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal