1. json转字符串
String requestStr = JSON.toJSONString(requestObj);
2. json转对象
String responseStr = HttpHelper.post(targetUrl, requestStr, token);
Object[] responseObj = JSON.parseObject(responseStr, Object[].class);
3. 一个对象成员变量值复制到另一对象中:
使用package org.springframework.beans;包下的BeanUtils.copyProperties(source, target);即可
BeanUtils.copyProperties(request, MDevice);
复制的数据在request中,使用时用.访问
4. 字符串转json:
String responseStr = HttpHelper.post(url, requestStr, token);
JSONObject responseJson = (JSONObject) JSON.parse(responseStr);