Hi
We are trying to parse the response from of REST command "/v2.0/net/nodes" and then we are getting an error INVALID JSON format.
Below is the snippet of code.
@GET
@Produces(MediaType.APPLICATION_JSON)
/* it returns the device information in a way the this
* Device is connected with the particular switch.
*/
private String getDeviceInfo(String hostMac) {
IpAddress ipAddress;
ipAddress=IpAddress.valueOf("127.0.0.1");
URI uri = restClient.uri(ipAddress, BASE_DESTINATION_PATH);
ResponseData response = restClient.get(restClient.login(), uri);
String responseData;
try {
responseData = new String(response.data(), StringUtils.UTF8);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(
"Unable to decode response from " + ipAddress, e);
}
log.warn("in getdeviceinfo() going to parse>>>>>>>.........");
List<Switch> remote=jsonService.fromJsonList(responseData, Switch.class);
log.warn("in getdeviceinfo() with mac returned as"+ remote.get(0).getMac());
return null;
}
The higlighted line generates an error :-
Caused by: com.hp.util.json.JsonCodecException: Invalid JSON format.
at com.hp.util.json.AbstractJsonCodec.decodeList(AbstractJsonCodec.java:119)
at com.hp.util.json.JSON.fromJsonList(JSON.java:82)
at com.hp.sdn.rs.FlareJsonProvider.fromJsonList(FlareJsonProvider.java:87)
at com.aricent.test.impl.LoadBalancerManager.getDeviceInfo(LoadBalancerManager.java:860)
at com.aricent.test.impl.LoadBalancerManager.check(LoadBalancerManager.java:562)
at com.aricent.test.impl.LoadBalancerManager.activate(LoadBalancerManager.java:254)
... 57 common frames omitted
Are we missing anything, any help will be appreciated.
Thanks
Gurtej