The following issues were found
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_Object_2_public.java
9 issues
Line: 13
public class WriteAsArray_Object_2_public extends TestCase {
public void test_0() throws Exception {
A a = new A();
a.setId(123);
a.setName("wenshao");
VO vo = new VO();
Reported by PMD.
Line: 26
Assert.assertEquals("[1001,[123,\"wenshao\"]]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getValue().getId(), vo2.getValue().getId());
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
Reported by PMD.
Line: 26
Assert.assertEquals("[1001,[123,\"wenshao\"]]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getValue().getId(), vo2.getValue().getId());
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
Reported by PMD.
Line: 26
Assert.assertEquals("[1001,[123,\"wenshao\"]]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getValue().getId(), vo2.getValue().getId());
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
Reported by PMD.
Line: 27
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getValue().getId(), vo2.getValue().getId());
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
private int id;
Reported by PMD.
Line: 27
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getValue().getId(), vo2.getValue().getId());
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
private int id;
Reported by PMD.
Line: 27
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getValue().getId(), vo2.getValue().getId());
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
private int id;
Reported by PMD.
Line: 30
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
private int id;
private A value;
public int getId() {
Reported by PMD.
Line: 53
}
public static class A {
private int id;
private String name;
public int getId() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1700/Issue1764_bean.java
9 issues
Line: 11
import static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;
public class Issue1764_bean extends TestCase {
public void test_for_issue() throws Exception {
assertEquals("{\"value\":\"9007199254741992\"}"
, JSON.toJSONString(
new Model(9007199254741992L)));
assertEquals("{\"value\":\"9007199254741990\"}"
Reported by PMD.
Line: 11
import static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;
public class Issue1764_bean extends TestCase {
public void test_for_issue() throws Exception {
assertEquals("{\"value\":\"9007199254741992\"}"
, JSON.toJSONString(
new Model(9007199254741992L)));
assertEquals("{\"value\":\"9007199254741990\"}"
Reported by PMD.
Line: 12
public class Issue1764_bean extends TestCase {
public void test_for_issue() throws Exception {
assertEquals("{\"value\":\"9007199254741992\"}"
, JSON.toJSONString(
new Model(9007199254741992L)));
assertEquals("{\"value\":\"9007199254741990\"}"
, JSON.toJSONString(
Reported by PMD.
Line: 16
, JSON.toJSONString(
new Model(9007199254741992L)));
assertEquals("{\"value\":\"9007199254741990\"}"
, JSON.toJSONString(
new Model(9007199254741990L)));
assertEquals("{\"value\":100}"
, JSON.toJSONString(
Reported by PMD.
Line: 20
, JSON.toJSONString(
new Model(9007199254741990L)));
assertEquals("{\"value\":100}"
, JSON.toJSONString(
new Model(100L)));
assertEquals("{\"value\":\"-9007199254741990\"}"
, JSON.toJSONString(
Reported by PMD.
Line: 24
, JSON.toJSONString(
new Model(100L)));
assertEquals("{\"value\":\"-9007199254741990\"}"
, JSON.toJSONString(
new Model(-9007199254741990L)));
assertEquals("{\"value\":-9007199254740990}"
, JSON.toJSONString(
Reported by PMD.
Line: 28
, JSON.toJSONString(
new Model(-9007199254741990L)));
assertEquals("{\"value\":-9007199254740990}"
, JSON.toJSONString(
new Model(-9007199254740990L)));
}
Reported by PMD.
Line: 38
@JSONType(serialzeFeatures = BrowserCompatible)
public static class Model {
public long value;
public Model() {
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.issue_1700;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.annotation.JSONType;
import junit.framework.TestCase;
import static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_shortArray.java
9 issues
Line: 20
String text = JSON.toJSONString(map, SerializerFeature.WriteClassName);
System.out.println(text);
Map map2 = JSON.parseObject(text, HashMap.class);
Map.Entry entry = (Map.Entry) map2.entrySet().iterator().next();
Assert.assertEquals(entry.getKey().getClass(), Short.class);
Assert.assertTrue(entry.getValue() instanceof Short);
Reported by PMD.
Line: 14
import com.alibaba.fastjson.serializer.SerializerFeature;
public class Bug_for_shortArray extends TestCase {
public void test_for_shor_array() throws Exception {
HashMap map = new HashMap();
map.put((short) 1, (short)-1);
String text = JSON.toJSONString(map, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 22
System.out.println(text);
Map map2 = JSON.parseObject(text, HashMap.class);
Map.Entry entry = (Map.Entry) map2.entrySet().iterator().next();
Assert.assertEquals(entry.getKey().getClass(), Short.class);
Assert.assertTrue(entry.getValue() instanceof Short);
}
}
Reported by PMD.
Line: 23
System.out.println(text);
Map map2 = JSON.parseObject(text, HashMap.class);
Map.Entry entry = (Map.Entry) map2.entrySet().iterator().next();
Assert.assertEquals(entry.getKey().getClass(), Short.class);
Assert.assertTrue(entry.getValue() instanceof Short);
}
}
Reported by PMD.
Line: 23
System.out.println(text);
Map map2 = JSON.parseObject(text, HashMap.class);
Map.Entry entry = (Map.Entry) map2.entrySet().iterator().next();
Assert.assertEquals(entry.getKey().getClass(), Short.class);
Assert.assertTrue(entry.getValue() instanceof Short);
}
}
Reported by PMD.
Line: 23
System.out.println(text);
Map map2 = JSON.parseObject(text, HashMap.class);
Map.Entry entry = (Map.Entry) map2.entrySet().iterator().next();
Assert.assertEquals(entry.getKey().getClass(), Short.class);
Assert.assertTrue(entry.getValue() instanceof Short);
}
}
Reported by PMD.
Line: 24
Map map2 = JSON.parseObject(text, HashMap.class);
Map.Entry entry = (Map.Entry) map2.entrySet().iterator().next();
Assert.assertEquals(entry.getKey().getClass(), Short.class);
Assert.assertTrue(entry.getValue() instanceof Short);
}
}
Reported by PMD.
Line: 24
Map map2 = JSON.parseObject(text, HashMap.class);
Map.Entry entry = (Map.Entry) map2.entrySet().iterator().next();
Assert.assertEquals(entry.getKey().getClass(), Short.class);
Assert.assertTrue(entry.getValue() instanceof Short);
}
}
Reported by PMD.
Line: 25
Map map2 = JSON.parseObject(text, HashMap.class);
Map.Entry entry = (Map.Entry) map2.entrySet().iterator().next();
Assert.assertEquals(entry.getKey().getClass(), Short.class);
Assert.assertTrue(entry.getValue() instanceof Short);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3400/Issue_20201016_01.java
9 issues
Line: 21
String s = JSON.toJSONString(config, SerializerFeature.WriteMapNullValue,
SerializerFeature.QuoteFieldNames, SerializerFeature.WriteNullListAsEmpty);
System.out.println(s);
}
public void testFastJson() {
String s = "{\"agent\":null,\"creator\":{\"account\":\"account\",\"name\":\"name\",\"workid\":null},\"owner\":{\"$ref\":\"$.creator\"}}";
Reported by PMD.
Line: 28
public void testFastJson() {
String s = "{\"agent\":null,\"creator\":{\"account\":\"account\",\"name\":\"name\",\"workid\":null},\"owner\":{\"$ref\":\"$.creator\"}}";
System.out.println( JSON.parseObject(s, Config.class));
}
public static class Config {
private UserConfig creator;
private UserConfig owner;
Reported by PMD.
Line: 9
import junit.framework.TestCase;
public class Issue_20201016_01 extends TestCase {
public void testToString() {
UserConfig user = new UserConfig();
user.setAccount("account");
user.setName("name");
Config config = new Config();
Reported by PMD.
Line: 9
import junit.framework.TestCase;
public class Issue_20201016_01 extends TestCase {
public void testToString() {
UserConfig user = new UserConfig();
user.setAccount("account");
user.setName("name");
Config config = new Config();
Reported by PMD.
Line: 25
}
public void testFastJson() {
String s = "{\"agent\":null,\"creator\":{\"account\":\"account\",\"name\":\"name\",\"workid\":null},\"owner\":{\"$ref\":\"$.creator\"}}";
System.out.println( JSON.parseObject(s, Config.class));
}
Reported by PMD.
Line: 25
}
public void testFastJson() {
String s = "{\"agent\":null,\"creator\":{\"account\":\"account\",\"name\":\"name\",\"workid\":null},\"owner\":{\"$ref\":\"$.creator\"}}";
System.out.println( JSON.parseObject(s, Config.class));
}
Reported by PMD.
Line: 31
System.out.println( JSON.parseObject(s, Config.class));
}
public static class Config {
private UserConfig creator;
private UserConfig owner;
private UserConfig agent;
public UserConfig getCreator() {
Reported by PMD.
Line: 56
}
}
public static class UserConfig {
private String workid;
private String name;
private String account;
public String getWorkid() {
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.issue_3400;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
public class Issue_20201016_01 extends TestCase {
public void testToString() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1600/Issue1683.java
9 issues
Line: 9
import junit.framework.TestCase;
public class Issue1683 extends TestCase {
public void test_for_issue() throws Exception {
String line = "[2, \"浪漫奇侠\", \"雨天不打伞\", 4536]";
BookDO book = JSON.parseObject(line, BookDO.class, Feature.SupportArrayToBean);
assertEquals(2L, book.bookId.longValue());
assertEquals("浪漫奇侠", book.bookName);
assertEquals("雨天不打伞", book.authorName);
Reported by PMD.
Line: 9
import junit.framework.TestCase;
public class Issue1683 extends TestCase {
public void test_for_issue() throws Exception {
String line = "[2, \"浪漫奇侠\", \"雨天不打伞\", 4536]";
BookDO book = JSON.parseObject(line, BookDO.class, Feature.SupportArrayToBean);
assertEquals(2L, book.bookId.longValue());
assertEquals("浪漫奇侠", book.bookName);
assertEquals("雨天不打伞", book.authorName);
Reported by PMD.
Line: 12
public void test_for_issue() throws Exception {
String line = "[2, \"浪漫奇侠\", \"雨天不打伞\", 4536]";
BookDO book = JSON.parseObject(line, BookDO.class, Feature.SupportArrayToBean);
assertEquals(2L, book.bookId.longValue());
assertEquals("浪漫奇侠", book.bookName);
assertEquals("雨天不打伞", book.authorName);
assertEquals(4536, book.wordCount.intValue());
}
Reported by PMD.
Line: 12
public void test_for_issue() throws Exception {
String line = "[2, \"浪漫奇侠\", \"雨天不打伞\", 4536]";
BookDO book = JSON.parseObject(line, BookDO.class, Feature.SupportArrayToBean);
assertEquals(2L, book.bookId.longValue());
assertEquals("浪漫奇侠", book.bookName);
assertEquals("雨天不打伞", book.authorName);
assertEquals(4536, book.wordCount.intValue());
}
Reported by PMD.
Line: 13
String line = "[2, \"浪漫奇侠\", \"雨天不打伞\", 4536]";
BookDO book = JSON.parseObject(line, BookDO.class, Feature.SupportArrayToBean);
assertEquals(2L, book.bookId.longValue());
assertEquals("浪漫奇侠", book.bookName);
assertEquals("雨天不打伞", book.authorName);
assertEquals(4536, book.wordCount.intValue());
}
@JSONType(orders = {"bookId", "bookName", "authorName", "wordCount"})
Reported by PMD.
Line: 14
BookDO book = JSON.parseObject(line, BookDO.class, Feature.SupportArrayToBean);
assertEquals(2L, book.bookId.longValue());
assertEquals("浪漫奇侠", book.bookName);
assertEquals("雨天不打伞", book.authorName);
assertEquals(4536, book.wordCount.intValue());
}
@JSONType(orders = {"bookId", "bookName", "authorName", "wordCount"})
public static class BookDO {
Reported by PMD.
Line: 15
assertEquals(2L, book.bookId.longValue());
assertEquals("浪漫奇侠", book.bookName);
assertEquals("雨天不打伞", book.authorName);
assertEquals(4536, book.wordCount.intValue());
}
@JSONType(orders = {"bookId", "bookName", "authorName", "wordCount"})
public static class BookDO {
Reported by PMD.
Line: 15
assertEquals(2L, book.bookId.longValue());
assertEquals("浪漫奇侠", book.bookName);
assertEquals("雨天不打伞", book.authorName);
assertEquals(4536, book.wordCount.intValue());
}
@JSONType(orders = {"bookId", "bookName", "authorName", "wordCount"})
public static class BookDO {
Reported by PMD.
Line: 19
}
@JSONType(orders = {"bookId", "bookName", "authorName", "wordCount"})
public static class BookDO {
private Long bookId;
private String bookName;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_primitive_short.java
9 issues
Line: 23
public static class VO {
private short value;
public short getValue() {
return value;
}
Reported by PMD.
Line: 25
private short value;
public short getValue() {
return value;
}
public void setValue(short value) {
throw new UnsupportedOperationException();
Reported by PMD.
Line: 29
return value;
}
public void setValue(short value) {
throw new UnsupportedOperationException();
}
}
}
Reported by PMD.
Line: 9
public class Bug_for_primitive_short extends TestCase {
public void test_emptyStr() throws Exception {
JSON.parseObject("{\"value\":\"\"}", VO.class);
}
public void test_null() throws Exception {
JSON.parseObject("{\"value\":null}", VO.class);
Reported by PMD.
Line: 9
public class Bug_for_primitive_short extends TestCase {
public void test_emptyStr() throws Exception {
JSON.parseObject("{\"value\":\"\"}", VO.class);
}
public void test_null() throws Exception {
JSON.parseObject("{\"value\":null}", VO.class);
Reported by PMD.
Line: 13
JSON.parseObject("{\"value\":\"\"}", VO.class);
}
public void test_null() throws Exception {
JSON.parseObject("{\"value\":null}", VO.class);
}
public void test_strNull() throws Exception {
JSON.parseObject("{\"value\":\"null\"}", VO.class);
Reported by PMD.
Line: 13
JSON.parseObject("{\"value\":\"\"}", VO.class);
}
public void test_null() throws Exception {
JSON.parseObject("{\"value\":null}", VO.class);
}
public void test_strNull() throws Exception {
JSON.parseObject("{\"value\":\"null\"}", VO.class);
Reported by PMD.
Line: 17
JSON.parseObject("{\"value\":null}", VO.class);
}
public void test_strNull() throws Exception {
JSON.parseObject("{\"value\":\"null\"}", VO.class);
}
public static class VO {
Reported by PMD.
Line: 17
JSON.parseObject("{\"value\":null}", VO.class);
}
public void test_strNull() throws Exception {
JSON.parseObject("{\"value\":\"null\"}", VO.class);
}
public static class VO {
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/PrimitiveArraySerializer.java
9 issues
Line: 24
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class PrimitiveArraySerializer implements ObjectSerializer {
public static PrimitiveArraySerializer instance = new PrimitiveArraySerializer();
public final void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
Reported by PMD.
Line: 24
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class PrimitiveArraySerializer implements ObjectSerializer {
public static PrimitiveArraySerializer instance = new PrimitiveArraySerializer();
public final void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
Reported by PMD.
Line: 28
public static PrimitiveArraySerializer instance = new PrimitiveArraySerializer();
public final void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull(SerializerFeature.WriteNullListAsEmpty);
return;
Reported by PMD.
Line: 28
public static PrimitiveArraySerializer instance = new PrimitiveArraySerializer();
public final void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull(SerializerFeature.WriteNullListAsEmpty);
return;
Reported by PMD.
Line: 28
public static PrimitiveArraySerializer instance = new PrimitiveArraySerializer();
public final void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull(SerializerFeature.WriteNullListAsEmpty);
return;
Reported by PMD.
Line: 28
public static PrimitiveArraySerializer instance = new PrimitiveArraySerializer();
public final void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull(SerializerFeature.WriteNullListAsEmpty);
return;
Reported by PMD.
Line: 28
public static PrimitiveArraySerializer instance = new PrimitiveArraySerializer();
public final void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull(SerializerFeature.WriteNullListAsEmpty);
return;
Reported by PMD.
Line: 28
public static PrimitiveArraySerializer instance = new PrimitiveArraySerializer();
public final void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull(SerializerFeature.WriteNullListAsEmpty);
return;
Reported by PMD.
Line: 134
}
char[] chars = (char[]) object;
out.writeString(chars);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1600/Issue_for_gaorui.java
9 issues
Line: 8
import junit.framework.TestCase;
public class Issue_for_gaorui extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"@type\":\"java.util.HashMap\",\"COUPON\":[{\"@type\":\"com.alibaba.json.bvt.issue_1600.Issue_for_gaorui.PromotionTermDetail\",\"activityId\":\"1584034\",\"choose\":true,\"couponId\":1251068987,\"couponType\":\"limitp\",\"match\":true,\"realPrice\":{\"amount\":0.6,\"currency\":\"USD\"}}],\"grayTrade\":\"true\"}";
JSON.parseObject(json, Object.class, Feature.SupportAutoType);
}
Reported by PMD.
Line: 8
import junit.framework.TestCase;
public class Issue_for_gaorui extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"@type\":\"java.util.HashMap\",\"COUPON\":[{\"@type\":\"com.alibaba.json.bvt.issue_1600.Issue_for_gaorui.PromotionTermDetail\",\"activityId\":\"1584034\",\"choose\":true,\"couponId\":1251068987,\"couponType\":\"limitp\",\"match\":true,\"realPrice\":{\"amount\":0.6,\"currency\":\"USD\"}}],\"grayTrade\":\"true\"}";
JSON.parseObject(json, Object.class, Feature.SupportAutoType);
}
Reported by PMD.
Line: 14
JSON.parseObject(json, Object.class, Feature.SupportAutoType);
}
public static class PromotionTermDetail {
/**
* 卡券Id
*/
private Long couponId;
/**
Reported by PMD.
Line: 40
/**
* 是否能够获取到该优惠
*/
private boolean isMatch = false;
/**
* 是否选择了该优惠
*/
private boolean isChoose = false;
/**
Reported by PMD.
Line: 40
/**
* 是否能够获取到该优惠
*/
private boolean isMatch = false;
/**
* 是否选择了该优惠
*/
private boolean isChoose = false;
/**
Reported by PMD.
Line: 40
/**
* 是否能够获取到该优惠
*/
private boolean isMatch = false;
/**
* 是否选择了该优惠
*/
private boolean isChoose = false;
/**
Reported by PMD.
Line: 44
/**
* 是否选择了该优惠
*/
private boolean isChoose = false;
/**
* 未获取到优惠的原因
*/
private String reasonForLose;
/**
Reported by PMD.
Line: 44
/**
* 是否选择了该优惠
*/
private boolean isChoose = false;
/**
* 未获取到优惠的原因
*/
private String reasonForLose;
/**
Reported by PMD.
Line: 44
/**
* 是否选择了该优惠
*/
private boolean isChoose = false;
/**
* 未获取到优惠的原因
*/
private String reasonForLose;
/**
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest_unwrapped_2.java
9 issues
Line: 13
public class JSONFieldTest_unwrapped_2 extends TestCase {
public void test_jsonField() throws Exception {
String text = "{\"id\":123,\"latitude\":37,\"longitude\":127}";
Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text);
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
Reported by PMD.
Line: 13
public class JSONFieldTest_unwrapped_2 extends TestCase {
public void test_jsonField() throws Exception {
String text = "{\"id\":123,\"latitude\":37,\"longitude\":127}";
Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text);
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
Reported by PMD.
Line: 18
Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text);
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
assertEquals(37, vo2.properties.get("latitude"));
assertEquals(127, vo2.properties.get("longitude"));
}
Reported by PMD.
Line: 19
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
assertEquals(37, vo2.properties.get("latitude"));
assertEquals(127, vo2.properties.get("longitude"));
}
public static class VO {
Reported by PMD.
Line: 19
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
assertEquals(37, vo2.properties.get("latitude"));
assertEquals(127, vo2.properties.get("longitude"));
}
public static class VO {
Reported by PMD.
Line: 20
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
assertEquals(37, vo2.properties.get("latitude"));
assertEquals(127, vo2.properties.get("longitude"));
}
public static class VO {
public int id;
Reported by PMD.
Line: 20
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
assertEquals(37, vo2.properties.get("latitude"));
assertEquals(127, vo2.properties.get("longitude"));
}
public static class VO {
public int id;
Reported by PMD.
Line: 27
public static class VO {
public int id;
private Map<String, Object> properties = new LinkedHashMap<String, Object>();
@JSONField(unwrapped = true)
public void setProperty(String key, Object value) {
properties.put(key, value);
}
Reported by PMD.
Line: 27
public static class VO {
public int id;
private Map<String, Object> properties = new LinkedHashMap<String, Object>();
@JSONField(unwrapped = true)
public void setProperty(String key, Object value) {
properties.put(key, value);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_Collection2.java
9 issues
Line: 22
A a = new A();
a.setList(Collections.singletonList(new B()));
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection2$A\",\"list\":[{}]}",
text);
A a1 = (A) JSON.parse(text);
Reported by PMD.
Line: 14
import com.alibaba.fastjson.serializer.SerializerFeature;
public class WriteClassNameTest_Collection2 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection2");
}
public void test_list() throws Exception {
A a = new A();
Reported by PMD.
Line: 15
public class WriteClassNameTest_Collection2 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection2");
}
public void test_list() throws Exception {
A a = new A();
a.setList(Collections.singletonList(new B()));
Reported by PMD.
Line: 18
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection2");
}
public void test_list() throws Exception {
A a = new A();
a.setList(Collections.singletonList(new B()));
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection2$A\",\"list\":[{}]}",
Reported by PMD.
Line: 28
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
public static class A {
Reported by PMD.
Line: 28
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
public static class A {
Reported by PMD.
Line: 29
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
public static class A {
private Collection<B> list;
Reported by PMD.
Line: 29
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
public static class A {
private Collection<B> list;
Reported by PMD.
Line: 29
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
public static class A {
private Collection<B> list;
Reported by PMD.