You need to sign in to do that
Don't have an account?
pranavshah
String To Json Conversion
How can i convert the below string in the web service class in JSON..
please help..
@RestResource(urlMapping='/Account/*')
global with sharing class NewCustCreation
{
//public String Status {get;set;}
//public List<Account> Data {get;set;}
//public String Message {get;set;}
//public String ErrorCode {get; set;}
public class Account
{
public String Name;
}
@HttpPost
global static String dopost(String Name)
{
system.debug('-----------Name----------------------'+Name);
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
Account account = new Account();
account.name=name;
String success = 'Welcome to Salesforce';
String error = 'Error';
if(Name!= '')
{
return Name;
}
else
{
return error;
}
}
please help..
@RestResource(urlMapping='/Account/*')
global with sharing class NewCustCreation
{
//public String Status {get;set;}
//public List<Account> Data {get;set;}
//public String Message {get;set;}
//public String ErrorCode {get; set;}
public class Account
{
public String Name;
}
@HttpPost
global static String dopost(String Name)
{
system.debug('-----------Name----------------------'+Name);
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
Account account = new Account();
account.name=name;
String success = 'Welcome to Salesforce';
String error = 'Error';
if(Name!= '')
{
return Name;
}
else
{
return error;
}
}
string to JSON conversion.
use this JSON class Method:
public static System.JSONParser createParser(String jsonString).
More about details please visit this link:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm
Please mark as best answer if it helps you.
Thanks
Akshay