Created on 02-18-2020 08:42 AM - last edited on 02-18-2020 11:17 AM by ask_bill_brooks
Please can you give me an example of how i would extract the "test" values from the below json
I tried the following but not winning ,
$.outputs.name.test1
$.test1
$.outputs.test1
I am using the processor "evaluate json path"
The below is a response from a webservice I am calling . I want the "test" values to be inserted in a sql table
"outputs": [
{
"name": "test1",
"value": "1"
},
{
"name": "test2",
"value": 0.9512272865085364
},
{
"name": "test3",
"value": 0.9512272865085364
},
{
"name": "test4",
"value": "1"
},
{
"name": "test5",
"value": 4.4659
},
{
"name": "test6",
"value": 0.048772713491463618
}
]
}
Created 02-19-2020 12:04 AM
Ok so me and my mate figured it out :). Finally!
its like this
$.outputs[?(@.name=="EM_CLASSIFICATION")].value
Created 02-18-2020 09:50 AM
First of all I think there is a { missing at the begin of your JSON.
You can try here for example: http://jsonpath.herokuapp.com/
Basically it works with $.outputs..name
Created on 02-18-2020 09:59 AM - last edited on 02-18-2020 11:16 AM by ask_bill_brooks
As mentioned above, make sure you are sending full JSON Object. Then in your EvaluateJsonPath processor click a + for each one you want to map to an attribute. Then enter the key → values as below:
test1 → $.outputs.test1
test2 → $.outputs.test2
test3 → $.outputs.test3
test4 → $.outputs.test4
test5 → $.outputs.test5
test6 → $.outputs.test6
If this solution works please accept it as the solution to close the topic.
Created 02-18-2020 02:17 PM
Thanks for your help @stevenmatison and @justenji .
I have managed to get the below json attributes successfully with simple $.AtrributeName
{
"test" : "7",
"dm0001al" : "-2",
"pp0406ln" : "5",
"pp0935cl" : "121",
"eq0001fl" : "-1",
"pp0406cl" : "1352",
"pp0934cc" : "-2",
"pp0026al" : "0",
"pp0035al" : "8",
"pp0901lb" : "-2",
"id" : 4,
"inputs" : [ {
"name" : "test",
"value" : 3
}, {
"name" : "dm0001al",
"value" : 1
}, {
"name" : "pp0406ln",
"value" : 1
}, {
"name" : "pp0935cl",
"value" : 1
}, {
"name" : "eq0001fl",
"value" : 1
}, {
"name" : "pp0406cl",
"value" : 1
}, {
"name" : "pp0934cc",
"value" : 1
}, {
"name" : "pp0026al",
"value" : 1
}, {
"name" : "pp0035al",
"value" : 1
}, {
"name" : "pp0901lb",
"value" : 1
} ]
}
But I am still struggling with the below one I tried a couple of tricks in EvalutuateIJson processor but still not values are assigning to attributes:
The content of my incoming flow is in full JSon and looks like the below. This is the full json
{
"outputs" : [ {
"name" : "EM_CLASSIFICATION",
"value" : "1"
}, {
"name" : "EM_EVENTPROBABILITY",
"value" : 0.9512272865085364
}, {
"name" : "EM_PROBABILITY",
"value" : 0.9512272865085364
}, {
"name" : "I_Responded",
"value" : "1"
}, {
"name" : "MSLR_woe",
"value" : 4.4659
}, {
"name" : "P_Responded0",
"value" : 0.048772713491463615
}, {
"name" : "P_Responded1",
"value" : 0.9512272865085364
}, {
"name" : "dm0001al_woe",
"value" : 0.853
}, {
"name" : "eq0001fl_woe",
"value" : 0.9315
}, {
"name" : "pp0026al_woe",
"value" : -0.2929
}, {
"name" : "pp0035al_woe",
"value" : 0.5839
}, {
"name" : "pp0406cl_woe",
"value" : 0.6062
}, {
"name" : "pp0406ln_woe",
"value" : 1.3878
}, {
"name" : "pp0901lb_woe",
"value" : 0.1952
}, {
"name" : "pp0934cc_woe",
"value" : -1.3256
}, {
"name" : "pp0935cl_woe",
"value" : -0.5781
} ]
}
I tried
$.outputs.pp0935cl_woe
$.outputs..pp0935cl_woe
$.['pp0935cl_woe']
$.outputs.name.pp0935cl_woe
Still nothing coming through in the attributes.
Any suggestions?
Thanks
Created 02-18-2020 04:37 PM
Try:
$.outputs.['EM_CLASSIFICATION']
that's $.mainobject.['array name'] to access the value for that outputs array item
Fun with Json...
Created 02-18-2020 11:12 PM
Tried it still nothing assigning
and tried all the below
$.['EM_CLASSIFICATION']
$.{EM_CLASSIFICATION}
$.{'EM_CLASSIFICATION'}
$.'{outputs.EM_CLASSIFICATION}'
$.outputs.{'EM_CLASSIFICATION'}
$.outputs.{EM_CLASSIFICATION}
$.outputs.{'name.EM_CLASSIFICATION'}
$.outputs.['..EM_CLASSIFICATION']
$.outputs.{'name'..'EM_CLASSIFICATION'}
might just plonk the full json in nvarchar field in sql and sql it out properly over their.
Created 02-19-2020 12:04 AM
Ok so me and my mate figured it out :). Finally!
its like this
$.outputs[?(@.name=="EM_CLASSIFICATION")].value