diff --git a/src/org/redkale/convert/json/JsonReader.java b/src/org/redkale/convert/json/JsonReader.java index 0b0976a9d..b2ab6643e 100644 --- a/src/org/redkale/convert/json/JsonReader.java +++ b/src/org/redkale/convert/json/JsonReader.java @@ -476,10 +476,16 @@ public class JsonReader extends Reader { } } if (expected != '"' && expected != '\'') { - if (expected == 'n' && ((text0.length == currpos + 4 && (text0[1 + currpos] == 'u' && text0[2 + currpos] == 'l' && text0[3 + currpos] == 'l')) - || (text0.length > currpos + 4 && (text0[1 + currpos] == 'u' && text0[2 + currpos] == 'l' && text0[3 + currpos] == 'l') - && (text0[4 + currpos] == ',' || text0[4 + currpos] <= ' ' || text0[4 + currpos] == '}' || text0[4 + currpos] == ']' || text0[4 + currpos] == ':')))) { - return null; + if (expected == 'n' && text0.length > currpos + 3 && (text0[1 + currpos] == 'u' && text0[2 + currpos] == 'l' && text0[3 + currpos] == 'l')) { + if (text0[++currpos] == 'u' && text0[++currpos] == 'l' && text0[++currpos] == 'l') { + this.position = currpos; + if (text0.length > currpos + 4) { + char ch = text0[currpos + 1]; + if (ch == ',' || ch <= ' ' || ch == '}' || ch == ']' || ch == ':') return null; + } else { + return null; + } + } } else { final int start = currpos; for (;;) { @@ -492,8 +498,8 @@ public class JsonReader extends Reader { this.position = currpos - 1; return new String(text0, start, currpos - start); } - //this.position = currpos; - //throw new ConvertException("expected a ':' after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")"); + this.position = currpos; + throw new ConvertException("expected a ':' after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")"); } final int start = ++currpos; for (;;) { diff --git a/test/org/redkale/test/convert/JsonTestMain.java b/test/org/redkale/test/convert/JsonTestMain.java index 960abce92..67b0545e9 100644 --- a/test/org/redkale/test/convert/JsonTestMain.java +++ b/test/org/redkale/test/convert/JsonTestMain.java @@ -21,7 +21,7 @@ public class JsonTestMain { public static void main(String[] args) throws Exception { JsonFactory factory = JsonFactory.root().tiny(true); final JsonConvert convert = JsonConvert.root(); - String json = "{\"access_token\":\"vVX2bIjN5P9TMOphDkStM96eNWapAehTuWAlVDO74aFaYxLwj2b-9-T9p_W2mfr9\",\"expires_in\":7200, \"aa\":\"\"}"; + String json = "{\"access_token\":\"vVX2bIjN5P9TMOphDkStM96eNWapAehTuWAlVDO74aFaYxLwj2b-9-T9p_W2mfr9\",\"priv\":null,\"priv2\":\"nulla\",\"expires_in\":7200, \"aa\":\"\"}"; Map map = convert.convertFrom(JsonConvert.TYPE_MAP_STRING_STRING, json); System.out.println(map); System.out.println(convert.convertTo(map));