- Community Home
- >
- Networking
- >
- Software Defined Networking
- >
- Re: getting Error Invalid Json Format
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-19-2014 06:06 AM
08-19-2014 06:06 AM
getting Error Invalid Json Format
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-02-2014 11:21 AM
09-02-2014 11:21 AM
Re: getting Error Invalid Json Format
Hello Gurtej,
Please make sure that the BASE_DESTINATION_PATH( which is of type String for e.g. "sdn/hm/v1.0/switches" ) , restClient (which is of type ServiceRest) and jsonService (which is of JsonService) is properly defined in the code.Also check that Switch.class is properly included.
If you are still facing the problem , please share your code.
Thanks,
HP SDN Team
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP