You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upon debugging, I found that issue is in InPlaceApplyProcessor.addToObject() API where it tries to set attributes field in parent contact Json instead of adding to existing array.
vikaskr0704
changed the title
JsonPatch.apply replacing array type field value when operation is ADD
JsonPatch.apply replacing array type field value when operation is ADD instead of APPEND
Oct 20, 2023
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
The text was updated successfully, but these errors were encountered: