Skip to main content

  "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

              }

            ]

          }

        ]

      }

    }

  ]

}
5 respuestas
  1. 21 jun 2022, 05:14
    Hi Rushikesh,

    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
0/9000