[
https://issues.apache.org/jira/browse/SOLR-9442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15664719#comment-15664719
]
Hoss Man commented on SOLR-9442:
--------------------------------
I know i'm a little late to the party, but this new format seems overly
cumbersome to parse -- for a given "NamedValuePair" the only constant is that
_if_ the JSON "name" attribute exists, then it's value will be a String telling
you the name of this Pair -- if it does not exist, then you know this pair has
no name. But in order to know either the type or the value of the Pair you have
to either know beforehand what to expect, or iterate -- either over the
possibly type values ("int","str",etc...), or over the list of attribute keys
in the Pair (ignoring "name").
It seems like a better structure (that would still maintain the original goal
of parity with the amount of data returned in the XML format) would be..
{noformat}
NamedList("a"=1,"b"=2,null=3)
=> [{"name":"a", "type":"int", "value":1},
{"name":"b", "type":"int", "value":2},
{"name":null, "type":"int", "value":3}]
NamedList("a"=1,"bar”=“foo",null=3.4f)
=> [{"name":"a", "type":"int", "value":1},
{"name":"b", "type":"str", "value":"foo"},
{"name":null, "type":"float", "value":3.4}]
NamedList("bar”=null,null=true)
=> [{"name":"bar", "type":"null", "value":null},
{"name":null, "type":"bool", "value":true}]
{noformat}
...the key improvement (in my mind) being: The set of JSON attributes is fixed
for all Pairs: "name", "type", and "value". Clients can always look for those
3 attributes to learn everything they can learn from the equivalent XML output.
[~cpoerschke] & [~jm100] - what do you think? better then what we have now?
> Add json.nl=arrnvp (array of NamedValuePair) style in JSONResponseWriter
> ------------------------------------------------------------------------
>
> Key: SOLR-9442
> URL: https://issues.apache.org/jira/browse/SOLR-9442
> Project: Solr
> Issue Type: Improvement
> Security Level: Public(Default Security Level. Issues are Public)
> Components: Response Writers
> Reporter: Jonny Marks
> Assignee: Christine Poerschke
> Priority: Minor
> Fix For: master (7.0), 6.4
>
> Attachments: SOLR-9442.patch, SOLR-9442.patch, SOLR-9442.patch
>
>
> The JSONResponseWriter class currently supports several styles of NamedList
> output format, documented on the wiki at http://wiki.apache.org/solr/SolJSON
> and in the code at
> https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/response/JSONResponseWriter.java#L71-L76.
> For example the 'arrmap' style:
> {code}NamedList("a"=1,"b"=2,null=3) => [{"a":1},{"b":2},3]
> NamedList("a"=1,"bar”=“foo",null=3.4f) => [{"a":1},{"bar”:”foo"},{3.4}]{code}
> This patch creates a new style ‘arrnvp’ which is an array of named value
> pairs. For example:
> {code}NamedList("a"=1,"b"=2,null=3) =>
> [{"name":"a","int":1},{"name":"b","int":2},{"int":3}]
> NamedList("a"=1,"bar”=“foo",null=3.4f) =>
> [{"name":"a","int":1},{"name":"b","str":"foo"},{"float":3.4}]{code}
> This style maintains the type information of the values, similar to the xml
> format:
> {code:xml}<lst name=“someField”>
> <int name=“a”>1</int>
> <str name=“bar”>foo</str>
> <float>3.4</float>
> </lst>{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]