Re: JSON from Term Vectors Component

2020-02-06 Thread Doug Turnbull
FWIW, I ended up writing some code that does a best effort turning the named list into a dict representation, if it can't, it'll keep it as a python tuple. def every_other_zipped(lst): return zip(lst[0::2],lst[1::2]) def dictify(nl_tups): """ Return dict if all keys unique, otherwise

Re: JSON from Term Vectors Component

2020-02-06 Thread Edward Ribeiro
Python's json lib will convert text as '{"id": 1, "id": 2}' to a dict, that doesn't allow duplicate keys. The solution in this case is to inject your own parsing logic as explained here: https://stackoverflow.com/questions/29321677/python-json-parser-allow-duplicate-keys One possible solution (bel

Re: JSON from Term Vectors Component

2020-02-06 Thread Walter Underwood
It is one of those things that happens when you don’t have a working group beat on a spec for six months. With an IETF process, I bet JSON would disallow duplicate keys and have comments. It might even have a datetime data type or at least recommend ISO8601 in a string. I was on the Atom workin

Re: JSON from Term Vectors Component

2020-02-06 Thread Doug Turnbull
Well that is interesting, I did not know that! Thanks Walter... https://stackoverflow.com/questions/21832701/does-json-syntax-allow-duplicate-keys-in-an-object I gave it a go in Python (what I'm using) to see what would happen, indeed it gives some odd behavior In [4]: jsonStr = ' {"test": 1, "t

Re: JSON from Term Vectors Component

2020-02-06 Thread Walter Underwood
Repeated keys are quite legal in JSON, but many libraries don’t support that. It does look like that data layout could be redesigned to be more portable. wunder Walter Underwood wun...@wunderwood.org http://observer.wunderwood.org/ (my blog) > On Feb 6, 2020, at 8:38 AM, Doug Turnbull > wrote

Re: JSON from Term Vectors Component

2020-02-06 Thread Doug Turnbull
Thanks for the tip, The issue is json.nl produces non-standard json with duplicate keys. Solr generates the following, which json lint fails given multiple keys { "positions": { "position": 155, "position": 844, "position": 1726 } } On Thu, Feb 6, 2020 at 11:36 AM Munendra S N wrote: > > > > N

Re: JSON from Term Vectors Component

2020-02-06 Thread Munendra S N
> > Notice the lists, within lists, within lists. Where the keys are adjacent > items in the list. Is there a reason this isn't a JSON dictionary? > I think this is because of NamedList. Have you tried using json.nl=map as a query parameter for this case? Regards, Munendra S N On Thu, Feb 6, 20

JSON from Term Vectors Component

2020-02-06 Thread Doug Turnbull
Hi all, I was curious if anyone had any tips on parsing the JSON response of the term vectors component? Or anyway to force it to be more standard JSON? It appears to be very heavily nested and idiosyncratic JSON, such as below. Notice the lists, within lists, within lists. Where the keys are adj