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

Commit

Permalink
improved compatible, fix #3544
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Nov 21, 2020
1 parent 8b690ff commit a7f1f5c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ public static Map parseMap(DefaultJSONParser parser, Map<String, Object> map, Ty

int token = lexer.token();
if (token != JSONToken.LBRACE) {
if (token == JSONToken.LITERAL_STRING) {
String stringVal = lexer.stringVal();
if (stringVal.length() == 0 || stringVal.equals("null")) {
return null;
}
}

String msg = "syntax error, expect {, actual " + lexer.tokenName();
if (fieldName instanceof String) {
msg += ", fieldName ";
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/com/alibaba/json/bvt/issue_3500/Issue3544.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.alibaba.json.bvt.issue_3500;

import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import lombok.Getter;
import lombok.Setter;

import java.util.Map;

public class Issue3544 extends TestCase {

public void test_errorType() {
assertNull("", JSON.toJavaObject(
JSON.parseObject("{\"result\":\"\"}"), TestVO.class).result);

assertNull("", JSON.toJavaObject(
JSON.parseObject("{\"result\":\"null\"}"), TestVO.class).result);
}

@Getter
@Setter
static class TestVO {

Map<String, String> result;

}
}

0 comments on commit a7f1f5c

Please sign in to comment.