hello,
I need to delete single line (“shippingProfileId”: “”) from the below json.
{
“createTransactionRequest”: {
“merchantAuthentication”: {
“name”: “”,
“transactionKey”: “”
},
“transactionRequest”: {
“transactionType”: “authCaptureTransaction”,
“amount”: “”,
“profile”: {
“customerProfileId”: “”,
“paymentProfile”: { “paymentProfileId”: “” },
“shippingProfileId”: “”
},
“order”: {
“invoiceNumber”: “”,
“description”: “”
},
“tax”: {
“amount”: “”
},
“shipping”: {
“amount”: “”
},
“authorizationIndicatorType”: {
“authorizationIndicator”: “final”
}
}
}
}
thanks!
ppr
(Peter Preuss)
2
@Stefan_Germanov
Welcome to the forum
We assume that the JSON was deserialized:
output: myJObject
So we can remove the shippingProfileId Property by:
TargetObject:
myJObject.SelectToken("..profile").Value(of JObject).Property("shippingProfileId")
Parvathy
(PS Parvathy)
3
Hi @Stefan_Germanov
Try this:
Deserialize JSON
- Input: Your JSON string
Assign
- To: jsonData
- Value: jsonNewtonsoft.Json.JsonConvert.DeserializeObject(Of Newtonsoft.Json.Linq.JObject)(Your JSON string)
Assign
- To: jsonData.SelectToken("createTransactionRequest.transactionRequest.profile.shippingProfileId")
- Value: Nothing
Assign
- To: updatedJsonString
- Value: jsonNewtonsoft.Json.JsonConvert.SerializeObject(jsonData, Newtonsoft.Json.Formatting.Indented)
Hope it helps!!
ppr
(Peter Preuss)
4
May we ask you to share with us a screenshot of this implemented step? Thanks
thanks!
Could you please explain how SelectToken path works?
In case there are multiple keys with value “profile” can we use specific path?
ppr
(Peter Preuss)
6
A JSON Path is used for the retrival
https://goessner.net/articles/JsonPath/
SelectToken - for a single return
SelectTokens - for a multi return
1 Like
system
(system)
Closed
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.