Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bug fixed for TypeUtils

  • Loading branch information...
commit a9f054c920550f7a861c99455fa9e1b9e5ba5521 1 parent d8d6606
wenshao authored
View
8 pom.xml
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
- <version>1.1.23</version>
+ <version>1.1.24-SNAPSHOT</version>
<packaging>jar</packaging>
<name>fastjson</name>
@@ -259,6 +259,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>xom</groupId>
+ <artifactId>xom</artifactId>
+ <version>1.2.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
View
4 src/main/java/com/alibaba/fastjson/util/TypeUtils.java
@@ -774,6 +774,10 @@ public static final Boolean castToBoolean(Object value) {
Class<?> componentType = loadClass(className.substring(1));
return Array.newInstance(componentType, 0).getClass();
}
+
+ if (className.startsWith("L") && className.endsWith(";")) {
+ className = className.substring(1, className.length() - 1);
+ }
try {
clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
View
37 src/test/java/com/alibaba/json/bvt/parser/ClassTest.java
@@ -0,0 +1,37 @@
+package com.alibaba.json.bvt.parser;
+
+import com.alibaba.fastjson.JSON;
+
+import junit.framework.TestCase;
+
+public class ClassTest extends TestCase {
+
+ public void test_class() throws Exception {
+ String text = "{\"clazz\":\"[Ljava.lang.String;\",\"value\":\"[\\\"武汉银行\\\"]\"}";
+
+ VO vo = JSON.parseObject(text, VO.class);
+ }
+
+ public static class VO {
+
+ private Class<?> clazz;
+ private Object value;
+
+ public Class<?> getClazz() {
+ return clazz;
+ }
+
+ public void setClazz(Class<?> clazz) {
+ this.clazz = clazz;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ }
+}
View
26 src/test/java/com/alibaba/json/test/JSONLibXmlTest.java
@@ -0,0 +1,26 @@
+package com.alibaba.json.test;
+
+import junit.framework.TestCase;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+import net.sf.json.xml.XMLSerializer;
+
+public class JSONLibXmlTest extends TestCase {
+ public void test_xml() throws Exception {
+ XMLSerializer xmlSerializer = new XMLSerializer();
+
+ JSONObject json = new JSONObject();
+ json.put("id", 123);
+ json.put("name", "jobs");
+ json.put("flag", true);
+
+ JSONArray items = new JSONArray();
+ items.add("x");
+ items.add(234);
+ items.add(false);
+ json.put("items", items);
+
+ String text = xmlSerializer.write(json);
+ System.out.println(text);
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.