mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-29 06:06:50 +08:00
bug fixed
This commit is contained in:
@@ -151,8 +151,8 @@ public final class JSONReaderScanner extends JSONLexer {
|
||||
|
||||
if (sp > 0) {
|
||||
if (this.token == JSONToken.LITERAL_STRING) {
|
||||
System.arraycopy(buf, np + 1, buf, 0, sp);
|
||||
np = -1;
|
||||
System.arraycopy(buf, buf.length - sp, buf, 0, sp);
|
||||
np = -1 + sp;
|
||||
} else {
|
||||
System.arraycopy(buf, bufLength - sp, buf, 0, sp);
|
||||
np = 0;
|
||||
@@ -186,7 +186,6 @@ public final class JSONReaderScanner extends JSONLexer {
|
||||
System.arraycopy(buf, offset, dest, 0, count);
|
||||
}
|
||||
|
||||
|
||||
public final boolean charArrayCompare(char[] chars) {
|
||||
for (int i = 0; i < chars.length; ++i) {
|
||||
if (charAt(bp + i) != chars[i]) {
|
||||
|
||||
@@ -20,9 +20,9 @@ package com.alibaba.fastjson.parser;
|
||||
*/
|
||||
public class SymbolTable {
|
||||
|
||||
public static final int DEFAULT_TABLE_SIZE = 128;
|
||||
public static final int DEFAULT_TABLE_SIZE = 256;
|
||||
public static final int MAX_BUCKET_LENTH = 8;
|
||||
public static final int MAX_SIZE = 1024;
|
||||
public static final int MAX_SIZE = 2048;
|
||||
|
||||
private final Entry[] buckets;
|
||||
private final String[] symbols;
|
||||
@@ -34,6 +34,8 @@ public class SymbolTable {
|
||||
|
||||
public SymbolTable(){
|
||||
this(DEFAULT_TABLE_SIZE);
|
||||
this.addSymbol("$ref", 0, 4, "$ref".hashCode());
|
||||
this.addSymbol("@type", 0, 4, "@type".hashCode());
|
||||
}
|
||||
|
||||
public SymbolTable(int tableSize){
|
||||
|
||||
@@ -140,6 +140,10 @@ public class JavaBeanSerializer implements ObjectSerializer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!FilterUtils.applyName(serializer, object, fieldSerializer.getName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Object propertyValue = fieldSerializer.getPropertyValue(object);
|
||||
|
||||
|
||||
@@ -84,49 +84,16 @@ public class MapSerializer implements ObjectSerializer {
|
||||
if (entryKey == null || entryKey instanceof String) {
|
||||
String key = (String) entryKey;
|
||||
|
||||
List<PropertyPreFilter> namePreFilters = serializer.getPropertyPreFiltersDirect();
|
||||
if (namePreFilters != null) {
|
||||
boolean apply = true;
|
||||
for (PropertyPreFilter nameFilter : namePreFilters) {
|
||||
if (!nameFilter.apply(serializer, object, key)) {
|
||||
apply = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!apply) {
|
||||
continue;
|
||||
}
|
||||
if (!FilterUtils.applyName(serializer, object, key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<PropertyFilter> propertyFilters = serializer.getPropertyFiltersDirect();
|
||||
if (propertyFilters != null) {
|
||||
boolean apply = true;
|
||||
for (PropertyFilter propertyFilter : propertyFilters) {
|
||||
if (!propertyFilter.apply(object, key, value)) {
|
||||
apply = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!apply) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
List<NameFilter> nameFilters = serializer.getNameFiltersDirect();
|
||||
if (nameFilters != null) {
|
||||
for (NameFilter nameFilter : nameFilters) {
|
||||
key = nameFilter.process(object, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
List<ValueFilter> valueFilters = serializer.getValueFiltersDirect();
|
||||
if (valueFilters != null) {
|
||||
for (ValueFilter valueFilter : valueFilters) {
|
||||
value = valueFilter.process(object, key, value);
|
||||
}
|
||||
if (!FilterUtils.apply(serializer, object, key, value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
key = FilterUtils.processKey(serializer, object, key, value);
|
||||
value = FilterUtils.processValue(serializer, object, key, value);
|
||||
|
||||
if (value == null) {
|
||||
if (!serializer.isEnabled(SerializerFeature.WriteMapNullValue)) {
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ObjectFieldSerializer extends FieldSerializer {
|
||||
if (fieldSerializer == null) {
|
||||
|
||||
if (propertyValue == null) {
|
||||
runtimeFieldClass = this.getMethod().getReturnType();
|
||||
runtimeFieldClass = this.fieldInfo.getFieldClass();
|
||||
} else {
|
||||
runtimeFieldClass = propertyValue.getClass();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.alibaba.json.bvt.parser;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.JSONReaderScanner;
|
||||
|
||||
public class JSONReaderScannerTest__entity_double_2 extends TestCase {
|
||||
|
||||
public void test_scanFloat() throws Exception {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append('[');
|
||||
for (int i = 0; i < 1024; ++i) {
|
||||
if (i != 0) {
|
||||
buf.append(',');
|
||||
}
|
||||
buf.append("{\"id\":" + i + ".0}");
|
||||
}
|
||||
buf.append(']');
|
||||
|
||||
Reader reader = new StringReader(buf.toString());
|
||||
|
||||
JSONReaderScanner scanner = new JSONReaderScanner(reader);
|
||||
|
||||
DefaultJSONParser parser = new DefaultJSONParser(scanner);
|
||||
List<VO> array = parser.parseArray(VO.class);
|
||||
for (int i = 0; i < array.size(); ++i) {
|
||||
Assert.assertTrue((double) i == array.get(i).getId());
|
||||
}
|
||||
parser.close();
|
||||
}
|
||||
|
||||
private static class VO {
|
||||
|
||||
private double id;
|
||||
|
||||
public double getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(double id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user