From 64166984f67425b62e701cd601b6708f60ec7aab Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Mon, 5 Feb 2007 18:22:04 +0000 Subject: [PATCH] handle null key for json.nl=flat git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@503795 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/solr/request/JSONResponseWriter.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/solr/request/JSONResponseWriter.java b/src/java/org/apache/solr/request/JSONResponseWriter.java index 9940a87359f..8f7fd5acebc 100644 --- a/src/java/org/apache/solr/request/JSONResponseWriter.java +++ b/src/java/org/apache/solr/request/JSONResponseWriter.java @@ -254,7 +254,6 @@ class JSONWriter extends TextResponseWriter { // NamedList("a"=1,"b"=2,null=3) => ["a",1,"b",2,null,3] protected void writeNamedListAsFlat(String name, NamedList val) throws IOException { int sz = val.size(); - indent(); writer.write('['); incLevel(); @@ -264,7 +263,11 @@ class JSONWriter extends TextResponseWriter { } String key = val.getName(i); indent(); - writeStr(null, key, true); + if (key==null) { + writeNull(null); + } else { + writeStr(null, key, true); + } writer.write(','); writeVal(key, val.getVal(i)); }