Skip to content

Commit

Permalink
add testcase for issue #505
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jun 25, 2022
1 parent 4148e28 commit 5b7fbbc
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions core/src/test/java/com/alibaba/fastjson2/issues/Issue505.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.alibaba.fastjson2.issues;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.PropertyNamingStrategy;
import com.alibaba.fastjson2.filter.NameFilter;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class Issue505 {
@Test
public void test() {
Bean bean = new Bean();
bean.userId = 101;

String str = JSON.toJSONString(bean, NameFilter.of(PropertyNamingStrategy.PascalCase));
assertEquals("{\"UserId\":101}", str);
JSONObject object = JSON.parseObject(str);
assertEquals(101, object.get("UserId"));
}

public static class Bean {
public int userId;
}
}

0 comments on commit 5b7fbbc

Please sign in to comment.