Unable to get a particular elements from JSON object

Hi All,

I’m having JSON object with me and I’m trying to get some of the values from that JSON object.I used Deserialize JSON activity to get my JSON object. From there I’m unable to extract the values from JSON object. I want the data as key and value pair or value for a particular sub JSON object.

Thanks,
Srikanth

1 Like

Kindly have a view on this link

Cheers @Srikanth_prem

1 Like

Take the following JSON for example:

{ 
   "GLOBAL":{
   "Var1":"one",
   "Var2":"two",
   "Var3":"three",
   "Arr1":["a","b","c","d"],
   },
   "DEV":{
       "site1":"www.xyz.com",
       "Var1":"a",
       "Arr1":["1","2","3","4"],
       "TEST":{
           "Var1":"TEST_Var1",
           "Var2":"TEST_Var2",
        },
    }
}

First: save the string to a variable, if this is saved as a config file, use the Read Text File Activity and output the text to a String Variable jsonString.

Second: use the Deserialize JSON Activity. Output this to a JObject Variable, I’ll refer to this as configJObject.

In order to reference each points of the JSON, you can use the following notation:
configJObject("Element Name").ToString

Nested Elements must be referred to explicitly. For example:
GLOBAL:
configJObject("GLOBAL")("Var1").ToString = one
configJObject("GLOBAL")("Var2").ToString = two
configJObject("GLOBAL")("Var3").ToString = three
configJObject("GLOBAL")("Arr1")(0).ToString = a
configJObject("GLOBAL")("Arr1")(1).ToString = b
configJObject("GLOBAL")("Arr1")(2).ToString = c
configJObject("GLOBAL")("Arr1")(3).ToString = d

DEV:
configJObject("DEV")("site1").ToString = www.xyz.com
configJObject("DEV")("Var1").ToString = a
configJObject("DEV")("Arr1")(0).ToString = 1
configJObject("DEV")("Arr1")(1).ToString = 2
configJObject("DEV")("Arr1")(2).ToString = 3
configJObject("DEV")("Arr1")(3).ToString = 4

DEV\TEST:
configJObject("DEV")("TEST")("Var1").ToString = TEST_Var1
configJObject("DEV")("TEST")("Var2").ToString = TEST_Var2

Image Example from Studio:

1 Like