-
Notifications
You must be signed in to change notification settings - Fork 156
Description
Expected Behavior
Op="ADD" should append an entry to array type field "attributes".
Original Json:
{
"id": "4c35b75c-6e1a-4bd2-8050-1137d485c76f",
"name": "PatientPanelsType",
"description": "This object contains the definition of patient panels",
"attributes": [
{
"name": "about",
"type": "String",
"editable": false,
"maxLength": 40,
"isRequired": true
},
{
"name": "contact",
"type": "Object",
"editable": false,
"attributes": [
{
"name": "phone",
"type": "String",
"editable": true,
"maxLength": 20,
"isRequired": true
},
{
"name": "email",
"type": "String",
"editable": true,
"maxLength": 256
}
],
"isRequired": true
}
]
}
Patch Json:
{
"op": "add",
"path": "/attributes/1/attributes",
"value": {
"name": "objIdentifier",
"type": "Object",
"attributes": [
{
"name": "identifierName",
"type": "String",
"maxLength": 256
},
{
"name": "identifierValue",
"type": "String",
"maxLength": 256
}
]
}
}
Expected Patched Json:
{
"id": "4c35b75c-6e1a-4bd2-8050-1137d485c76f",
"name": "PatientPanelsType",
"description": "This object contains the definition of patient panels",
"attributes": [
{
"name": "about",
"type": "String",
"editable": false,
"maxLength": 40,
"isRequired": true
},
{
"name": "contact",
"type": "Object",
"editable": false,
"attributes": [
{
"name": "phone",
"type": "String",
"editable": true,
"maxLength": 20,
"isRequired": true
},
{
"name": "email",
"type": "String",
"editable": true,
"maxLength": 256
},
{
"name": "objIdentifier",
"type": "Object",
"attributes": [
{
"name": "identifierName",
"type": "String",
"maxLength": 256
},
{
"name": "identifierValue",
"type": "String",
"maxLength": 256
}
]
}
],
"isRequired": true
}
]
}
Actual Behavior
Op="ADD" is replacing array type field "attributes" value with op ADD value.
Output of JsonPatch.apply(patch, originalJson) is below:
{
"id": "4c35b75c-6e1a-4bd2-8050-1137d485c76f",
"name": "PatientPanelsType",
"description": "This object contains the definition of patient panels",
"attributes": [
{
"name": "about",
"type": "String",
"editable": false,
"maxLength": 40,
"isRequired": true
},
{
"name": "contact",
"type": "Object",
"editable": false,
"attributes": {
"name": "objIdentifier",
"type": "Object",
"attributes": [
{
"name": "identifierName",
"type": "String",
"maxLength": 256
},
{
"name": "identifierValue",
"type": "String",
"maxLength": 256
}
]
},
"isRequired": true
}
]
}
Steps to Reproduce the Problem
origialJsonNode = objectMapper.valueToTree(
/Original Json from Expected behavior section/)
patchJsonNode = objectMapper.valueToTree(/Patch Json from Expected behavior section/)
JsonNode applyPatch = JsonPatch.apply(patchJsonNode, origialJsonNode);
Specifications
Library Version: 0.4.12 and 0.4.14
Language: Java 17.1