mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-28 22:04:04 +08:00
bug fixed for references. for jsonarray ref compute error.
This commit is contained in:
@@ -467,6 +467,12 @@ public class DefaultJSONParser implements Closeable {
|
||||
: lexer.text.charAt(index));
|
||||
}
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
final boolean parentIsArray = fieldName != null && fieldName.getClass() == Integer.class;
|
||||
if (!parentIsArray) {
|
||||
this.setContext(context);
|
||||
}
|
||||
|
||||
this.parseArray(list, key);
|
||||
value = new JSONArray(list);
|
||||
if (innerMap != null) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.alibaba.json.bvt.ref;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Created by wenshao on 16/8/23.
|
||||
*/
|
||||
public class RefTest22 extends TestCase {
|
||||
public void test_ref() throws Exception {
|
||||
String json = "{\"name\":\"123\",\"assetSize\":{},\"items\":[{\"id\":123}],\"refItems\":{\"$ref\":\"$.items[0]\"}}";
|
||||
JSONObject root = JSON.parseObject(json);
|
||||
assertSame(root.getJSONArray("items").get(0), root.getJSONObject("refItems"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user