主要难点在于判断前端传来的json是哪种形式的
body: {}
body: [{}, {}, {}]
比较优美的判断方式为
Object jsobj = JSONObject.parse(jsonStr);
if(jsobj instanceof JSONArray){
//JSONArray
}
if(jsobj instanceof JSONObject){
//JSONObject
}
来源:学无止境的苹果
主要难点在于判断前端传来的json是哪种形式的
body: {}
body: [{}, {}, {}]
比较优美的判断方式为
Object jsobj = JSONObject.parse(jsonStr);
if(jsobj instanceof JSONArray){
//JSONArray
}
if(jsobj instanceof JSONObject){
//JSONObject
}
来源:学无止境的苹果