How to parse the HTTP Response if response string is in name value pair.


1 Answer 1


There are many ways to parse it, but probably the simplest is to use String.split. Something like the following should get you started.

Map<String, String> payload = new Map<String, String>();
for (String pair : response.getBody().split('&'))
    List<String> data = pair.split('=', 2);
    String key = data[0], value = (data.size() > 1) ? data[1] : null;
    payload.put(key, value);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .