: Of course we might stumble across cases where ordering isn't important, : but multiple values with the same key is... While not the case for : facet counts, if it ever came up that could be handled (in a different : json.nl variant) by serializing with all same-keyed values collected : into an Array, at the expense of strict ordering: : : [["DupKey", [Val1, Val3, Val4]], ["AnotherKey", Val2]]
It comes down to a question of intent -- if the code producing the NamedList intended multiple uses of the same key to be interpreted as a single key refering ot a list of values, it could have created a Map where the values of some keyws was an array. : The SOLR NamedList is a simple analog of the element-tree part of XML : (no attributes or mixed content). This article gives a very thorough : summary of the mappings between XML and JSON which can be applied to the : NamedList->JSON issue as well: : : http://www.xml.com/lpt/a/1658 Hmmm... i only skimmed this but it seems that according to their rules of thumb, it's imposible to make either a reversable or semantically equivalent JSON structure out of a NamedList since neither of the following rules are garunted to be true... #1 all subelement names occur exactly once, or subelements with identical names are in sequence. #2 multiple homonymous subelements occur nonsequentially, and element order doesn't matter. : I stumbled across a Ruby OrderedHash which looks to be an analog of NamedList: : : http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/20551 i don't know RUby, but the cases i imagine that doesn't cover is key's pearing more then once, and values with no keys. -Hoss