Sign inSign up

msagency/msa-json-patch

By msagency

•Updated over 9 years ago

Microservice to generate a diff (rfc 6902) between two json documents

Image
1

1.2K

msagency/msa-json-patch repository overview

⁠msa-json-patch

Microservice to generate a diff (RFC 6902⁠) between two json documents A & B, that can be also used to transform/patch document A into document B.

If you have a given JSON document with a series of updates, this can be used to reduce the amount of data to send over the wire.

Built using jsonpatch⁠.

⁠Quick start

Execute the microservice container with the following command :

docker run -ti -p 9909:80 msagency/msa-json-patch
⁠Example(s)
$ curl -X POST "http://localhost:9909/json/diff" -H "Content-Type: application/json" \
-d '[{"name": "test","val": 10}, {"name": "test","val": 20}]'
{
  "data": "[{\"op\": \"replace\", \"value\": 20, \"path\": \"/val\"}]"
}

$ curl -X POST "http://localhost:9909/json/patch" -H "Content-Type: application/json" \
-d '[{"name": "test","val": 10}, [{ "op": "replace","path": "/val", "value": 20}]]'
{
  "data": {
    "name": "test",
    "val": 20
  }
}
⁠Endpoints
  • POST /json/diff⁠ : Returns a diff between two JSON documents A and B. Expected input is [A,B]
  • POST /json/patch⁠ : Returns the generated document B from patching the document A. Expected input is [A, patch]
⁠Standard endpoints
⁠About

A project by the Microservices Agency⁠.

Tag summary

Content type

Image

Digest

Size

47.4 MB

Last updated

over 9 years ago

docker pull msagency/msa-json-patch