forked from sofastack/sofa-rpc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bug sofastack#1254 for JSON serialization and deserialization
- Loading branch information
HISSs
committed
Feb 18, 2023
1 parent
af35a32
commit 7fcc3d9
Showing
2 changed files
with
42 additions
and
2 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
37 changes: 37 additions & 0 deletions
37
test/test-common/src/main/java/com/alipay/sofa/rpc/test/JSONTest.java
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,37 @@ | ||
package com.alipay.sofa.rpc.test; | ||
|
||
import com.alipay.sofa.rpc.common.json.JSON; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author github.com/gofow | ||
* @date 2023/02/18 16:55 | ||
**/ | ||
public class JSONTest { | ||
|
||
public static void main(String[] args) { | ||
BeanEntity bean = new JSONTest.BeanEntity(); | ||
|
||
Map<String, ? super ValueEntity> map = new HashMap<>(); | ||
map.put("1", new ValueEntity()); | ||
bean.map = map; | ||
|
||
String jsonString = JSON.toJSONString(bean); | ||
System.out.println(jsonString); | ||
|
||
bean.map.values().forEach(value -> { | ||
System.out.println(value.getClass().getSimpleName()); | ||
}); | ||
|
||
BeanEntity ans = JSON.parseObject(jsonString, BeanEntity.class); | ||
System.out.println(ans.map.get("1").getClass().getSimpleName()); | ||
} | ||
|
||
static class BeanEntity { | ||
Map<String, ? super ValueEntity> map; | ||
} | ||
|
||
static class ValueEntity {} | ||
} |