
On Sat, Jul 20, 2019 at 09:56:53AM -0400, Stewart C. Russell via talk wrote:
Hi William,
I'm writing automated test scripts. Unfortunately for me, input configuration is XML, and I use "xmlstarlet" to get data from that.
Another one for the XML side is Dan Egnor's xml2. It converts XML to a simple flat line-oriented format that works well with command line tools:
Trivial XML:
<xml> <blort>squarnk</blort> <mlem>-8</mlem> </xml>
Examples:
$ xml2 < triv.xml /xml/blort=squarnk /xml/mlem=-8
$ xml2 < triv.xml | grep blort | 2xml <xml><blort>squarnk</blort></xml>
I'm trying to avoid doing this kind of thing, because I will be spending way too much time dealing with corner cases. I already have! That's why I'm looking for "proper" parser.
Looks like "jq" is the answer. But, I find that "jq" ignores duplicate keys, and accepts only the last one. Major pain!
Wait, are you saying that the JSON has duplicate hash keys, like this:
{"blort":"squarnk","mlem":-8,"blort":"phweeen"}
(so, two values for the key "blort")? It really shouldn't do that, even though the file is valid JSON. Most JSON parsers only return the last value.
Yeah, something I noticed. :-( -- William Park <opengeometry@yahoo.ca>