You need to sign in to do that
Don't have an account?
rumit lumia
Compare json data
Hello,
I have two JSON, one I have generated based on my org data, and another I Ihave received from another system.
I have to compare each and every record present in these JSONs. I have unique external ID defined in every record (which can be used while comparing). Finally I have to make a list of similar and dis-simmilar records.
Can anyone suggest, how I can accomplish this task?
Br,
Rumit
I have two JSON, one I have generated based on my org data, and another I Ihave received from another system.
I have to compare each and every record present in these JSONs. I have unique external ID defined in every record (which can be used while comparing). Finally I have to make a list of similar and dis-simmilar records.
Can anyone suggest, how I can accomplish this task?
Br,
Rumit
1. Use JSON to Apex Parser and Generate the Apex Class from from Source One data ( Lets Suppose You get into the apex class List<SourceOneWrapper>
2 .Use JSON to Apex Parser and Generate the Apex Class from Source Two data ( Lets Suppose You get into the apex class List<SourceTwoWrapper>
3 . Create a Temp Apex Class wrapper this value hold the value
List<FinalApexClassWrapper > wrap = new list<FinalApexClassWrapper >
4 . Take one of the value as sournce lets take here source one as base
for( SourceOneWrapper so:LstSouOne){
For(SourceTwoWrapper so2: so2List){
if(so2.Id == so.Id){
//add to list
}else{
add to another list
}
}
}
Even You can able to use the Maps or Json Deseralixed types based on JSOn format
Thanks for your response. :)
The above method will surely work for sizeable JSON, and I'll try to incorporate it.
In my case, the JSONs are huge, I'm scared that it may run into CPU timeouts.
Is there any standard OOTB method defined, which may help me out as my JSONs contains records of standard sObjects.
Br,
Rumit