You need to sign in to do that
Don't have an account?
Rushikesh Agnihotri 46
"Results": [
{
"Result": {
"IsDB": "True",
"Spend": 453,
"Paths": [
{
"Technologies": [
{
"IsPremium": "no",
"Name": "SPF",
"Description": "The Sender Policy Framework is an open standard specifying a technical method to prevent sender address forgery.",
"Link": "http://www.openspf.org/",
"Tag": "mx",
"FirstDetected": 1566774000000,
"LastDetected": 1629702000000
}
]
}
]
}
}
]
}
Deserilize the json and get the Name value from technologies node
"Results": [
{
"Result": {
"IsDB": "True",
"Spend": 453,
"Paths": [
{
"Technologies": [
{
"IsPremium": "no",
"Name": "SPF",
"Description": "The Sender Policy Framework is an open standard specifying a technical method to prevent sender address forgery.",
"Link": "http://www.openspf.org/",
"Tag": "mx",
"FirstDetected": 1566774000000,
"LastDetected": 1629702000000
}
]
}
]
}
}
]
}
You can use the example listed in chttps://salesforce.stackexchange.com/questions/174388/how-to-deserialized-json-response-in-apex to get started
Happy to help if you are stuck somewhere
If this information helps, please mark the answer as best. Thank you
I had tried but as it have multiple nodes so not able to get that data
If my understanding is correct, you are trying to get the Name value of the Technologies node using JS.
If yes, PFB - for the same.
const resultvalue = {
"Results": [
{
"Result": {
"IsDB": "True",
"Spend": 453,
"Paths": [
{
"Technologies": [
{
"IsPremium": "no",
"Name": "SPF",
"Description": "The Sender Policy Framework is an open standard specifying a technical method to prevent sender address forgery.",
"Link": "http://www.openspf.org/",
"Tag": "mx",
"FirstDetected": 1566774000000,
"LastDetected": 1629702000000
}
]
}
]
}
}
]
};
console.log('### resultvalue: ', resultvalue);
resultvalue.Results.find(
rv => {
rv.Result.Paths.find(
pt => {
pt.Technologies.find(
tech => {
if (tech.Name) {
console.log('### Technologies Name is ', tech.Name);
}
}
);
}
);
}
);
Else, you shall use https://www.adminbooster.com/tool/json2apex for JSON to Apex conversion.
//
//Generated by AdminBooster
//
public class fromJSON{
public cls_Results[] Results;
class cls_Results {
public cls_Result Result;
}
class cls_Result {
public String IsDB; //True
public Integer Spend; //453
public cls_Paths[] Paths;
}
class cls_Paths {
public cls_Technologies[] Technologies;
}
class cls_Technologies {
public String IsPremium; //no
public String Name; //SPF
public String Description; //The Sender Policy Framework is an open standard specifying a technical method to prevent sender address forgery.
public String Link; //http://www.openspf.org/
public String Tag; //mx
public Integer FirstDetected; //1566774000000
public Integer LastDetected; //1629702000000
}
public static fromJSON parse(String json){
return (fromJSON) System.JSON.deserialize(json, fromJSON.class);
}
static testMethod void testParse() {
String json= '{'+
' "Results": ['+
' {'+
' "Result": {'+
' "IsDB": "True",'+
' "Spend": 453,'+
' "Paths": ['+
' {'+
' "Technologies": ['+
' {'+
' "IsPremium": "no",'+
' "Name": "SPF",'+
' "Description": "The Sender Policy Framework is an open standard specifying a technical method to prevent sender address forgery.",'+
' "Link": "http://www.openspf.org/",'+
' "Tag": "mx",'+
' "FirstDetected": 1566774000000,'+
' "LastDetected": 1629702000000'+
' }'+
' ]'+
' }'+
' ]'+
' }'+
' }'+
' ]'+
' }';
fromJSON obj = parse(json);
System.assert(obj != null);
}
}
If this helps you, please mark the answer as best.
Best Regards,
Sasid
https://trailblazer.me/id/sasid