JSON file Issue

Hi All,

I am working on a jsonfile and I should be able to get the values from the excel to this existing json and the sample json looks like below:
{
“id”: “1”,
“s1”: “t1”,
“s2”: “t2”,
“s3”: “t3”,
“fa1”: “1”,
“s4”: “1”,
“s5”: “1”,
“cc1”: {
“sk1”: “t4”,
“ac1”: “if”,
“pr1”: “t5”,
“gr1”: 1,
“cu1”: “re”,
“po1”: “t6”,
“cr1”: fa2,
“ad1”: {
“se1”: fa3,
“ch1”: [
“ch2”
],
“se2”: 1,
“en2”: t7
}
},
“sy1”: {
“al1”: “t8”,
“re1”: ,
“re2”: ,
“en3”: {
“01”:
}
},
“mi4”: {
“a1”: 1,
“gr1”: 5
},
“ex1”: {
“le1”: [
“Cu3”
],
“col2”: [
“S1”
]
},
“SS1”: ,
“CI2”: ,
“ip3”: {
“wh1”: [
“::9”
],
“bl2”: ,
“ra3”: {
“mi6”: 60,
“ra2”: 5
}
},
“ur3”: “http://abcdefgh.xyz:11111”,
“enr1”: [
“Mem1”,
“La1”,
“xyz”,
“abc”,
“qwer”
]
}
While i am taking the values from excel, deserializing the json and mapping the key n value in another datatable and trying to update it using a Invoke Method activity in the existing json i have encountered multiple errors as mentioned below:

  1. For gr1 which is present under 2 different keys still i get “Keys should be unique”.
  2. For the ::9 and the link http://abcdefgh.xyz:11111 throws up error and unless i dont remove the issue still persists.
  3. For enr1 ,while mapping in a datatable the values in it are getting typed in a single line. Whereas it should be the same as it looks in the json.

Any suggestions would be helpful.

1 Like

Hey @sophi.priyanka

So the conversion is from an Excel table to JSON ?

Thanks
#nK

There’s no conversion … I am just taking the values provided in excel to a datatable and mapping the keys to these values. So that Invoke method activity can replace the existing values and update it back in the json with the latest values.
Is that helpful?

1 Like

Hey @sophi.priyanka

What’s the method currently utilised in that updating part ?

Thanks
#nK

the Method name is Replace

1 Like

Hey @sophi.priyanka

Could you please show that particular statement please ?

Because the replace you are using how are you actually passing the value to replace ?

Thanks
#nK

Since its for each value in data table, am using a Invoke Method inside a for each row in data table
TargetObject =obj1.SelectToken(currentrow(“Values”).ToString)
Methodname = Replace
Parameters =JToken.FromObject(dtvalue(currentrow(“Keys”).toString))

1 Like

When you use Select Token you are trying to match key right ?

Is that coming in Excel ?

“Values” in Select token is the column name from the mapping datatable.

1 Like

Hey @sophi.priyanka

So you need to pass the column name, but you are currently passing the actual value.

Also if you can please explain with some screenshots would be great.

Thanks
#nK

For a better understanding please see the below link which I had raised few months ago.

I had followed d same steps what had been mentioned in the above link but I am getting errors for the json file which I shared in this post.

Any suggestions for this would be helpful

Any updates to this query?