0

Hi I need to store the certain part of the string and store it in a separate integer variable.

My Final

string getResult = {"httpStatus":200,"httpRequestUri":"/sfsImagingservices/documents/followup/annuity","message":"HTTP request succeeded"}

My req is to fetch the Httpstatus:200 in a seprate integer or variable.

req to help me out for this.

1 Answer 1

3

Your String is in fact valid JSON. Therefore, you can parse it into Map and get values by key.

Map<String, Object> ans = (Map<String, Object>) JSON.deserializeUntyped(getResult);
Integer toStore = (Integer) ans.get('httpStatus');
3
  • Can you please post here your actual code? At least, in the getResult String you do not have single-quotes. Sep 23, 2019 at 11:16
  • 1
    You probably need to cast the result of ans.get() to your target type (Integer, in this case).
    – Derek F
    Sep 23, 2019 at 11:16
  • Sorry actually here variable should be of Object type not Integer : Its working Thanks for your help :)
    – Raghav
    Sep 23, 2019 at 11:22

You must log in to answer this question.

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