Skip to main content

Recursively convert JSON including json-string to YAML

Project description

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.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rj2y-0.1.2.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

rj2y-0.1.2-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page