jsonPathPut

Description: The jsonPathPut function puts the key and scalar value at the specified JsonPath on a Subject JSON and returns string form of the updated JSON.

Subject Type: String

Arguments:

  • jsonPath : the JSON path expression to set value on the Subject.

  • value : the value expression to be set on the specified path on Subject.

  • key : the key expression with the associated value the specified path on Subject.

Return Type: String

Examples: If the "myJson" attribute is


{
     "firstName": "John",
     "lastName": "Smith",
     "age": 25,
     "voter" : true,
     "height" : 6.1,
     "address" : {
         "streetAddress": "21 2nd Street",
         "city": "New York",
         "state": "NY",
         "postalCode": "10021-3100"
     },
     "phoneNumbers": [
         {
             "type": "home",
             "number": "212 555-1234"
         },
         {
             "type": "office",
             "number": "646 555-4567"
         }
     ],
     "nicknames" : []
 }

Expression

Value

${myJson:jsonPathPut('$','middlename','Turon')}

{"firstName":"James", lastName":"Smith", "middlename": "Turon", "age":25, "voter":true, "height":6.1, "address":{"streetAddress":"21 2nd Street", "city":"New York", "state":"NY", "postalCode":"10021-3100"}, "phoneNumbers":[{"type":"home", "number":"212 555-1234"}, {"type":"office", "number":"646 555-4567"}]}

An empty subject value or a subject value with an invalid JSON document results in an exception bulletin.