You need to sign in to do that
Don't have an account?
Deepikareddy
Visualforce page:
Result:
After deserilizing with the StateInfodetails wrapperclass,iam gettng the values as null..! can anyone help me to resolve this solution. thanks you..
Salesforce Json Deserialization Concept
public class testingarryfuction { public StateInfodetails StateInfodetailswraper{get;set;} public testingarryfuction (){ string teststring ='{ "sucess":1,"data":{"Stateidselected":"2","StateInfodetails":{"stateName": "Andrapradesh","value": "apx" ,"rating":5}}}'; Map<String, Object> maptest = (Map<String, Object>) JSON.deserializeUntyped(teststring); system.debug('mapped and deserialized data is::'+maptest); Object ob = (Object)maptest.get('data'); system.debug('get data is::'+ob); String srlze = System.JSON.serialize(ob); system.debug('again deserailized is ::'+srlze ); StateInfodetailswraper = (StateInfodetails)System.JSON.deserialize(srlze,StateInfodetails.class); system.debug('deserilize using the wrapperclass::::::'+StateInfodetailswraper ); system.debug(StateInfodetailswraper.stateName); } //this is a wrapper class public class StateInfodetails{ public string stateName{get;set;} public string value{get;set;} public integer rating{get;set;} } }
Visualforce page:
<apex:page controller="testingarryfuction" > <apex:form > Name: <apex:inputText value="{!StateInfodetailswraper.stateName}" /> <br/><br/> Value: <apex:inputText value="{!StateInfodetailswraper.value}" /> <br/><br/> rating: <apex:inputText value="{!StateInfodetailswraper.rating}" /> <br/><br/> </apex:form> </apex:page>
Result:
After deserilizing with the StateInfodetails wrapperclass,iam gettng the values as null..! can anyone help me to resolve this solution. thanks you..
I've gone through your code and inside your code you must do below changes:
1.Remove the "data " from inside the teststring and it will work fine:
(i.e.)
string teststring ='{ "sucess":1,{"Stateidselected":"2","StateInfodetails":{"stateName": "Andrapradesh","value": "apx" ,"rating":5}}};
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
Thanks and regards,
deepika