Sujet : Re: Which newsgroup for json parsing?
De : anton.txt (at) *nospam* g{oogle}mail.com (Anton Shepelev)
Groupes : comp.lang.cDate : 08. May 2024, 14:21:46
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240508162146.61cfc58f4140a4a0074adab1@g{oogle}mail.com>
References : 1
User-Agent : Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Josef Mollers:
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 have reformatted your example, because it was a mess.
JSON is so easy to parse, that writing your own parser may
prove an interesting exercise for a couple of days. I used
the following site for reference:
<
https://www.json.org/json-en.html>
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()!
Have you checked the documentation?--
<
https://gnome.pages.gitlab.gnome.org/json-glib/func.gobject_from_data.html>
Additionally, the WIKI page has some examples:
<
https://wiki.gnome.org/Projects/JsonGlib>
I am also looking at libjson-c but cannot find any
examples that could guide me.
Have you checked the documentation?--
<
http://json-c.github.io/json-c/json-c-current-release/doc/html/index.html#using>
Observe that examples are optional in that they illustrate
documentation rather then provide it. It is better to learn
from first principles than from examples. See also:
<
http://json-c.github.io/json-c/json-c-current-release/doc/html/index.html#gettinghelp>
-- () ascii ribbon campaign -- against html e-mail/\ www.asciiribbon.org -- against proprietary attachments