<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/python-json-patch.git/doc/commandline.rst, branch master</title>
<subtitle>github.com: stefankoegl/python-json-patch.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-json-patch.git/'/>
<entry>
<title>Add support for preserving Unicode characters in jsonpatch CLI</title>
<updated>2021-03-03T07:54:40+00:00</updated>
<author>
<name>Genzer Hawker</name>
<email>genzers@gmail.com</email>
</author>
<published>2021-03-03T07:24:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-json-patch.git/commit/?id=974d54f393de78ce21bee9897cee8f1ace5813ee'/>
<id>974d54f393de78ce21bee9897cee8f1ace5813ee</id>
<content type='text'>
If the JSON content contains some Unicode characters, the jsonpatch
final output will encode the Unicode character using ASCII (i.e
`\u0394`). This behaviour comes from the module `json.dump()` governed
by a flag `ensure_ascii`[1].

For example:

```json
/* patch.json */
[{
  "op": "add",
  "path": "/SomeUnicodeSamples",
  "value": "𝒞𝘋𝙴𝓕ĢȞỈ𝕵 đ áê 🤩 äÄöÖüÜß"
}]
```

After applying the patch on an empty source file `{}`, this is the
output:

```json
{"SomeUnicodeSamples": "\ud835\udc9e\ud835\ude0b...\u00fc\u00dc\u00df"}
```

This commit adds a flag `-u|--preserve-unicode` in the jsonpatch CLI
to configure the behaviour of `json.dump`'s `ensure_ascii` flag.

Using the `--preserve-unicode` flag, the cli will print the Unicode
characters as-is without any encoding.

[1]: https://docs.python.org/3/library/json.html#basic-usage
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If the JSON content contains some Unicode characters, the jsonpatch
final output will encode the Unicode character using ASCII (i.e
`\u0394`). This behaviour comes from the module `json.dump()` governed
by a flag `ensure_ascii`[1].

For example:

```json
/* patch.json */
[{
  "op": "add",
  "path": "/SomeUnicodeSamples",
  "value": "𝒞𝘋𝙴𝓕ĢȞỈ𝕵 đ áê 🤩 äÄöÖüÜß"
}]
```

After applying the patch on an empty source file `{}`, this is the
output:

```json
{"SomeUnicodeSamples": "\ud835\udc9e\ud835\ude0b...\u00fc\u00dc\u00df"}
```

This commit adds a flag `-u|--preserve-unicode` in the jsonpatch CLI
to configure the behaviour of `json.dump`'s `ensure_ascii` flag.

Using the `--preserve-unicode` flag, the cli will print the Unicode
characters as-is without any encoding.

[1]: https://docs.python.org/3/library/json.html#basic-usage
</pre>
</div>
</content>
</entry>
<entry>
<title>add docs for commandline utilities</title>
<updated>2013-10-12T10:20:38+00:00</updated>
<author>
<name>Stefan Kögl</name>
<email>stefan@skoegl.net</email>
</author>
<published>2013-10-12T10:20:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-json-patch.git/commit/?id=2d2102c5e9aa8f2c915fa66d4eeb1db64a7bc221'/>
<id>2d2102c5e9aa8f2c915fa66d4eeb1db64a7bc221</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
