Skip to main content

rj2y

PyPI PyPI Python Versions Downloads

This CLI tool is a simple utility to convert JSON to YAML. Especially useful when you want to convert JSON including JSON-embedded string.

{
  "iii": "{\"i\":\"{\\\"ii\\\": \\\"ii\\\"}\",\"ii\":\"ii\"}",
  "kkk": "{\"k\": \"{\\\"kk\\\": \\\"kk1\\\\nkk2\\\\nkk3\\\\n\\\"}\"}"
}
iii:
  i:
    ii: !!str ii
  ii: !!str ii
kkk:
  k:
    kk: !!str |-
      kk1
      kk2
      kk3

It may be convenient to reading server logs. Using with jq and yq is recommended.

Installation

pipx install rj2y

Usage

cat some.json | rj2y
rj2y some.json

Example

input json and output yaml

https://github.com/pollenjp/rj2y-py/blob/d237729c54be84f1dd78542bf4bd2476c7a16e3a/tests/unittest/test_main.py#L6-L39

https://github.com/pollenjp/rj2y-py/blob/d237729c54be84f1dd78542bf4bd2476c7a16e3a/tests/unittest/test_main.py#L45-L109

Using yq make it easier to read.

cat some.json | rj2y | yq
aaa: !!str AAA
bbb: !!bool true
ccc: !!int 123
ccc2: !!str 123
ddd: !!float 123.456
ddd2: !!str 123.456
eee:
  - !!str e
  - !!str ee
  - !!str eee
fff:
  f: !!str f
  ff: !!str ff
  fff: !!str fff
ggg:
  - g: !!str g
    gg: !!str gg
    ggg: !!str ggg
  - g: !!str g
    gg: !!str gg
    ggg: !!str ggg
hhh:
  h: !!str h
  hh: !!str hh
  hhh: !!str hhh
iii:
  i:
    ii: !!str ii
  ii: !!str ii
jjj: !!str |-
  jj1
  jj2
  jj3
kkk:
  k:
    kk: !!str |-
      kk1
      kk2
      kk3

Metadata

Release files for rj2y 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rj2y 0.1.5
File Size Uploaded
rj2y-0.1.5.tar.gz 20.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rj2y 0.1.5
File Interpreter ABI Platform
rj2y-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 24.3 kB

Release files / rj2y-0.1.5.tar.gz

Download URL rj2y-0.1.5.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
735874df16d8bea0905426c5b40e02ace4535eea3b8157b023bcea065ff46f4d
BLAKE2b-256 checksum
How to use checksums
c5bb2708e0cfee885c5283cbce9db753735d5580fd696546b196d3d5a4ca1831
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / rj2y-0.1.5-py3-none-any.whl

Download URL rj2y-0.1.5-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a94f5b749685b92e355449a4378a662a36843c75314be41589c2a9075bfec385
BLAKE2b-256 checksum
How to use checksums
0f139831b143d3078553ea3be412cd340113fa9d3f3d6c860dc6aaa652498447
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page