Skip to content

JSON patch diff for op=add formation is not as per standard (RFC 6902) #1983

Closed
@harishmurkal

Description

Hi,

When result_json = diff(source, target) is called with

source = { "foo": [ "bar", "baz" ] }
dest = {"foo": [ "bar", "baz", "baa" ]}

NOTE: actual function is

static basic_json diff(const basic_json& source, const basic_json& target,
                       const std::string& path = "")

Obtained JSON is
result_json =
[
{ "op": "add", "path": "/foo/1", "value": "qux" }
]

This is wrong as per RFC 6902 (refer section 4.1)
https://tools.ietf.org/html/rfc6902#page-4

Expected is
result_json =
[
{ "op": "add", "path": "/foo/-", "value": "qux" }
]

Where is the problem here?

Or is it we need to interchange source and target to generate diff?
Waiting for your response.

Thanks and Regards,
Harish M

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions