mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-29 06:06:50 +08:00
bug fixed for issue #784
This commit is contained in:
@@ -1110,7 +1110,7 @@ public class DefaultJSONParser implements Closeable {
|
||||
}
|
||||
|
||||
try {
|
||||
final boolean first_quote;
|
||||
boolean first_quote;
|
||||
char ch = lexer.ch;
|
||||
if (ch != '"') {
|
||||
if (ch == ']') {
|
||||
@@ -1161,6 +1161,8 @@ public class DefaultJSONParser implements Closeable {
|
||||
|
||||
if (ch == '"') {
|
||||
continue;
|
||||
} else {
|
||||
first_quote = false;
|
||||
}
|
||||
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -1,7 +1,23 @@
|
||||
package com.alibaba.json.bvt.bug;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
/**
|
||||
* Created by wenshao on 16/8/24.
|
||||
*/
|
||||
public class Issue784 {
|
||||
public class Issue784 extends TestCase {
|
||||
public void test_for_issue() throws Exception {
|
||||
String json = "[\"150\",\"change\",{\"timeStamp\":1471595047319,\"value\":\"\"},{\"attrs\":{\"value\":\"\"}}]";
|
||||
JSONArray jsonArray = (JSONArray) JSON.parse(json);
|
||||
Assert.assertEquals("150", jsonArray.get(0));
|
||||
Assert.assertEquals("change", jsonArray.get(1));
|
||||
Assert.assertEquals(1471595047319L, jsonArray.getJSONObject(2).get("timeStamp"));
|
||||
Assert.assertEquals("", jsonArray.getJSONObject(2).get("value"));
|
||||
Assert.assertEquals("", jsonArray.getJSONObject(3).getJSONObject("attrs").get("value"));
|
||||
Assert.assertEquals(4, jsonArray.size());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user