Skip to content

Commit

Permalink
add Feature.NonStringKeyAsString, for issue #1633
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Dec 11, 2017
1 parent 5f051b8 commit 771e101
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/com/alibaba/fastjson/parser/Feature.java
Expand Up @@ -125,7 +125,12 @@ public enum Feature {
/**
* @since 1.2.41, backport to 1.1.66.android
*/
SupportAutoType
SupportAutoType,

/**
* @since 1.2.42
*/
NonStringKeyAsString
;

Feature(){
Expand Down
20 changes: 20 additions & 0 deletions src/test/java/com/alibaba/json/bvt/issue_1600/Issue1633.java
@@ -0,0 +1,20 @@
package com.alibaba.json.bvt.issue_1600;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import junit.framework.TestCase;

public class Issue1633 extends TestCase {
public void test_for_issue_int() throws Exception {
String text = "{123:\"abc\"}";
JSONObject obj = JSON.parseObject(text, Feature.NonStringKeyAsString);
assertEquals("abc", obj.getString("123"));
}

public void test_for_issue_bool() throws Exception {
String text = "{false:\"abc\"}";
JSONObject obj = JSON.parseObject(text, Feature.NonStringKeyAsString);
assertEquals("abc", obj.getString("false"));
}
}

0 comments on commit 771e101

Please sign in to comment.