-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug fixed for kotlin support,for issue #1750
- Loading branch information
Showing
3 changed files
with
74 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.alibaba.json.bvt.kotlin; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import junit.framework.TestCase; | ||
import org.apache.commons.io.IOUtils; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
public class Issue1750 extends TestCase { | ||
public void test_user() throws Exception { | ||
ExtClassLoader classLoader = new ExtClassLoader(); | ||
Class clazz = classLoader.loadClass("Issue1750_ProcessBO"); | ||
|
||
String json = "{\n" + | ||
"\t\"masterId\": \"1111111111111\",\n" + | ||
"\t\"processId\": \"222222222222222\",\n" + | ||
"\t\"taskId\": \"33333333333333\",\n" + | ||
"\t\"taskName\": \"44444444444444\"\n" + | ||
"}"; | ||
Object obj = JSON.parseObject(json, clazz); | ||
String result = JSON.toJSONString(obj); | ||
System.out.println(result); | ||
assertEquals("{\"masterId\":\"1111111111111\",\"processId\":\"222222222222222\",\"taskId\":\"33333333333333\",\"taskName\":\"44444444444444\"}", result); | ||
} | ||
|
||
private static class ExtClassLoader extends ClassLoader { | ||
|
||
public ExtClassLoader() throws IOException { | ||
super(Thread.currentThread().getContextClassLoader()); | ||
|
||
{ | ||
byte[] bytes; | ||
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/Issue1750_ProcessBO.clazz"); | ||
bytes = IOUtils.toByteArray(is); | ||
is.close(); | ||
|
||
super.defineClass("Issue1750_ProcessBO", bytes, 0, bytes.length); | ||
} | ||
} | ||
} | ||
} |
Binary file not shown.