Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
bug fixed for 'is' prefix fieldName parser. for issue #1529
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Oct 21, 2017
1 parent 51da853 commit e0640e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,8 @@ private boolean parseField(DefaultJSONParser parser, String key, Object object,
// smartMatchHashArrayMapping

int pos = Arrays.binarySearch(smartMatchHashArray, smartKeyHash);
if (pos < 0 && key.startsWith("is")) {
boolean is = false;
if (pos < 0 && (is = key.startsWith("is"))) {
smartKeyHash = TypeUtils.fnv_64_lower(key.substring(2));
pos = Arrays.binarySearch(smartMatchHashArray, smartKeyHash);
}
Expand All @@ -951,6 +952,10 @@ private boolean parseField(DefaultJSONParser parser, String key, Object object,
int deserIndex = smartMatchHashArrayMapping[pos];
if (deserIndex != -1) {
fieldDeserializer = sortedFieldDeserializers[deserIndex];
Class fieldClass = fieldDeserializer.fieldInfo.fieldClass;
if (is && (fieldClass != boolean.class && fieldClass != Boolean.class)) {
fieldDeserializer = null;
}
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/com/alibaba/json/bvt/issue_1500/Issue1529.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.alibaba.json.bvt.issue_1500;

import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;

public class Issue1529 extends TestCase {
public void test_for_issue() throws Exception {
String text = "{\"isId\":false,\"Id\":138042533,\"name\":\"example\",\"height\":172}";
JSON.parseObject(text, Person.class);
}

public static class Person {
public int Id;
public String name;
public double height;
}
}

0 comments on commit e0640e5

Please sign in to comment.