You need to sign in to do that
Don't have an account?

JSON Parser: Need help in understanding it
{"example":{"Os":"windows","Origin":"xyz"}} is my request string that is sent to a HTTPPost REST Web service in salesforce.
@RestResource(urlMapping='/NewIncident/*')
global without sharing class WSIncident {
@HttpPost
global static String createMobileCase(string example) {
contact newCase = new contact();
JSONParser jParser = JSON.createParser(example);
/*CAN SOME ONE PLEASE HELP ME PARSE THIS JSON*/
return newCase.Id;
}
}
@RestResource(urlMapping='/NewIncident/*')
global without sharing class WSIncident {
@HttpPost
global static String createMobileCase(string example) {
contact newCase = new contact();
JSONParser jParser = JSON.createParser(example);
/*CAN SOME ONE PLEASE HELP ME PARSE THIS JSON*/
return newCase.Id;
}
}
if (jparser.getCurrentToken() == JSONToken.FIELD_NAME){
if (jparser.getText() == 'Os'){
jparser.nextToken();
os = jparser.getText();
}
else{
jparser.nextToken();
origin = jparser.getText();
}
}
Above code gives me an error: Unexpected parameter encountered during deserialization: Os
Please!! Any help will be highly appreciated!!!