You need to sign in to do that
Don't have an account?
Jayant Kumar Jaiswal
response.getbody() is returning the JSON String with /n and /
I'm recieving the a JSON string in API response which is containing /n and / in between.
{\n \"Return Code\" : \"Ok\",\n \"Return Mess\" : \"No Error\",\n \"Time Zone\" : \"SA\",\n \"FNN Line Type Potent\" : \"AB\",\n \"Number Of FNNs Returned\" : 5,\n \"FNNs\" : [ {\n \"fnnExt\" : \"122525\",\n \"fnnNode\" : \"Node 1\",\n \"technology\" : \"S\",\n \"lastUsed\" : \"2017-04-25\",\n \"workingStatusCode\" : \"R\",\n \"remarks\" : \"No Remarks\",\n \"disconnectReason\" : \"TD\",\n \"quarantineDate\" : \"2017-06-05\",\n \"quarantineIndicator\" : \"Y\"\n }, {\n \"fnnExt\" : \"225632\",\n \"fnnNode\" : \"Node 2\",\n \"technology\" : \"S\",\n \"lastUsed\" : \"2017-08-04\",\n \"workingStatusCode\" : \"R\",\n \"remarks\" : \"No Remarks\",\n \"disconnectReason\" : \"TD\",\n \"quarantineDate\" : \"2017-08-02\",\n \"quarantineIndicator\" : \"Y\"\n }, {\n \"fnnExt\" : \"552365\",\n \"fnnNode\" : \"Node 3\",\n \"technology\" : \"S\",\n \"lastUsed\" : \"2017-07-06\",\n \"workingStatusCode\" : \"R\",\n \"remarks\" : \"No Remarks\",\n \"disconnectReason\" : \"TD\",\n \"quarantineDate\" : \"2017-02-26\",\n \"quarantineIndicator\" : \"Y\"\n }, {\n \"fnnExt\" : \"225417\",\n \"fnnNode\" : \"Node 4\",\n \"technology\" : \"S\",\n \"lastUsed\" : \"2017-01-05\",\n \"workingStatusCode\" : \"R\",\n \"remarks\" : \"No Remarks\",\n \"disconnectReason\" : \"DD\",\n \"quarantineDate\" : \"2017-02-10\",\n \"quarantineIndicator\" : \"Y\"\n }, {\n \"fnnExt\" : \"441256\",\n \"fnnNode\" : \"Node 5\",\n \"technology\" : \"S\",\n \"lastUsed\" : \"2017-04-02\",\n \"workingStatusCode\" : \"R\",\n \"remarks\" : \"No Remarks\",\n \"disconnectReason\" : \"DD\",\n \"quarantineDate\" : \"2017-06-04\",\n \"quarantineIndicator\" : \"Y\"\n } ]\n}
I am only using the Array part of JSON and i have a wrapper class for it as well.
I'm using below code to convert this Json Array to list of wrapper class.
while (parser.nextToken() != null) {
if (parser.getCurrentToken() == JSONToken.START_ARRAY) {
while (parser.nextToken() != null) {
if (parser.getCurrentToken() == JSONToken.START_OBJECT) {
FNN fnnRecord = (FNN)parser.readValueAs(FNN.class);
String s = JSON.serialize(fnnRecord);
system.debug('Serialized -----> ' + s);
fnnlist.add(fnnRecord);
// Skip the child start array and start object markers.
parser.skipChildren();
}
}
}
}
Now this peace of code works very well for if the JSON string doesn't contain /n and /. But since my response contains these characters the code is breaking.
Any solutions please.
Thanks
{\n \"Return Code\" : \"Ok\",\n \"Return Mess\" : \"No Error\",\n \"Time Zone\" : \"SA\",\n \"FNN Line Type Potent\" : \"AB\",\n \"Number Of FNNs Returned\" : 5,\n \"FNNs\" : [ {\n \"fnnExt\" : \"122525\",\n \"fnnNode\" : \"Node 1\",\n \"technology\" : \"S\",\n \"lastUsed\" : \"2017-04-25\",\n \"workingStatusCode\" : \"R\",\n \"remarks\" : \"No Remarks\",\n \"disconnectReason\" : \"TD\",\n \"quarantineDate\" : \"2017-06-05\",\n \"quarantineIndicator\" : \"Y\"\n }, {\n \"fnnExt\" : \"225632\",\n \"fnnNode\" : \"Node 2\",\n \"technology\" : \"S\",\n \"lastUsed\" : \"2017-08-04\",\n \"workingStatusCode\" : \"R\",\n \"remarks\" : \"No Remarks\",\n \"disconnectReason\" : \"TD\",\n \"quarantineDate\" : \"2017-08-02\",\n \"quarantineIndicator\" : \"Y\"\n }, {\n \"fnnExt\" : \"552365\",\n \"fnnNode\" : \"Node 3\",\n \"technology\" : \"S\",\n \"lastUsed\" : \"2017-07-06\",\n \"workingStatusCode\" : \"R\",\n \"remarks\" : \"No Remarks\",\n \"disconnectReason\" : \"TD\",\n \"quarantineDate\" : \"2017-02-26\",\n \"quarantineIndicator\" : \"Y\"\n }, {\n \"fnnExt\" : \"225417\",\n \"fnnNode\" : \"Node 4\",\n \"technology\" : \"S\",\n \"lastUsed\" : \"2017-01-05\",\n \"workingStatusCode\" : \"R\",\n \"remarks\" : \"No Remarks\",\n \"disconnectReason\" : \"DD\",\n \"quarantineDate\" : \"2017-02-10\",\n \"quarantineIndicator\" : \"Y\"\n }, {\n \"fnnExt\" : \"441256\",\n \"fnnNode\" : \"Node 5\",\n \"technology\" : \"S\",\n \"lastUsed\" : \"2017-04-02\",\n \"workingStatusCode\" : \"R\",\n \"remarks\" : \"No Remarks\",\n \"disconnectReason\" : \"DD\",\n \"quarantineDate\" : \"2017-06-04\",\n \"quarantineIndicator\" : \"Y\"\n } ]\n}
I am only using the Array part of JSON and i have a wrapper class for it as well.
I'm using below code to convert this Json Array to list of wrapper class.
while (parser.nextToken() != null) {
if (parser.getCurrentToken() == JSONToken.START_ARRAY) {
while (parser.nextToken() != null) {
if (parser.getCurrentToken() == JSONToken.START_OBJECT) {
FNN fnnRecord = (FNN)parser.readValueAs(FNN.class);
String s = JSON.serialize(fnnRecord);
system.debug('Serialized -----> ' + s);
fnnlist.add(fnnRecord);
// Skip the child start array and start object markers.
parser.skipChildren();
}
}
}
}
Now this peace of code works very well for if the JSON string doesn't contain /n and /. But since my response contains these characters the code is breaking.
Any solutions please.
Thanks