how to fetch specific value from json

Certified Associate Developer

Hi All , 

I have values stored in database in a particular field i.e. say previousValues, like below 

    • "{"name":"xyz","regDate":"2012-07-01","regStatus":"Completed"}"  --   (Text)

      Now my requirement is to fetch regStatus value from this format . 

      How can I achieve this

        Discussion posts and replies are publicly visible

      • 0
        Certified Lead Developer
        in reply to saurabh sharma

        How are they getting passed into "ri!valueToConvert" after being queried?  If they're coming in with the outer quotes somehow, those aren't a valid part of the JSON.

      • 0
        Certified Lead Developer
        in reply to saurabh sharma

        As you can see, all 3 of those are valid JSON and a!fromJson() works on them just fine.  In fact we can even manually set them as local variables (we just have to properly escape all internal quotes in that case to make them proper strings).

        a!localVariables(
          local!jsonArray: {
            "{""name"":""PQ"",""cStartDate"":""2012-07-01Z"",""eTerm"":""2028-06-30Z"",""sStatus"":""NA"",""t"":1110.0,""Months"":12,""Name"":"""",""Text"":""Eng"",""siteAccessConditionsIfApplicable"":""rDo not use  \n++++++++++++++++++++++++++++++++++++++++\n\n\n"",""cMer"":""GFTA""}",
        
            "{""name"":""PQ"",""cStartDate"":""2012-07-01Z"",""eTerm"":""2028-06-30Z"",""sStatus"":""NA"",""t"":1110.0,""Months"":12,""Name"":"""",""Text"":""Eng"",""siteAccessConditionsIfApplicable"":""rDo not use  \n++++++++++++++++++++++++++++++++++++++++\n\n\n"",""cMer"":""GFTA""}",
        
            "{""name"":""PQ"",""cStartDate"":""2012-07-01Z"",""eTerm"":""2028-06-30Z"",""sStatus"":""NA"",""t"":1110.0,""Months"":12,""Name"":"""",""Text"":""Eng"",""siteAccessConditionsIfApplicable"":""rDo not use  \n++++++++++++++++++++++++++++++++++++++++\n\n\n"",""cMer"":""GFTA""}"
          },
          
          a!forEach(
            local!jsonArray,
            a!fromJson(fv!item)
          )
        )