[collectd] curl_json woes - arrays and parsing errors
Dave Cottlehuber
dch at jsonified.com
Wed Mar 6 17:13:19 CET 2013
Hi,
I've been trying unsuccessfully to parse JSON data from a webservice
for using inside collectd --
{rows: [{
key: ["urgent"],
value: 8
}, {
key: ["low"],
value: 174
…
I'd like to be able to spit out a tuple `rows[0].key, rows[0].value`,
is this even possible?
Below is a slimmed down test using publically accessible endpoints.
- is it possible to extract an item from an array (see "data" below)
- why is the cherokee example causing an error? the json appears valid
using json_verify from yajl2 suite:
$ curl -s http://www.cherokee-project.com/about/info/js | json_verify
JSON is valid
NB full config and error here https://gist.github.com/dch/b31af6cae7cf5f525768
<Plugin curl_json>
<URL "https://qrng.anu.edu.au/API/jsonI.php?length=5&type=uint8">
#{
# "type": "uint8",
# "length": 5,
# "data": [ 20, 234, 108, 97, 13 ],
# "success": true
#}
Instance "random"
#<Key "length">
# Type "gauge"
#</Key>
<Key "data/*">
Type "gauge"
</Key>
</URL>
<URL "http://www.cherokee-project.com/about/info/js">
#{
# "version": "Cherokee web server 1.2",
# "traffic": {
# "tx": 247971700722,
# "rx": 3793223698,
Instance "cherokee"
<Key "traffic/tx">
Type "gauge"
</Key>
</URL>
</Plugin>
======= error ========
[2013-03-06 16:52:18] [error] curl_json plugin: yajl_parse failed:
parse error: premature EOF
786845, "tx": 1634174
(right here) ------^
A+
Dave
More information about the collectd
mailing list