{
"data": {
"userId": "yuliang.jin",
"subscriptionsBySpeaker": [
{
"speakerId": "1",
"speakerName": "张露"
}
],
"subscriptionsByCategory": [
{
"categoryId": "43",
"categoryName": "好饿啊"
},
{
"categoryId": "6",
"categoryName": "后台开发"
}
]
}
}
If we define the target json class in controller like below:
private String userId;
private List<SubscriptionBySpeakerDHO> subscriptionsBySpeaker;
private List<SubscriptionByCategoryDHO> subscriptionsByCategory;
then we can't get the json from client side, because it's not the right json. We have to define the json in the client side like bellow:
{
"userId": "yuliang.jin",
"subscriptionsBySpeaker": [
{
"speakerId": "1",
"speakerName": "张露"
}
],
"subscriptionsByCategory": [
{
"categoryId": "43",
"categoryName": "好饿啊"
},
{
"categoryId": "6",
"categoryName": "后台开发"
}
]
}
Only in this way, can we receive the json as a right object.