Skip to content

Instantly share code, notes, and snippets.

@pfuntner
Last active November 2, 2024 14:49
Show Gist options
  • Save pfuntner/cdf1e734371cafe904f78b6b836347e4 to your computer and use it in GitHub Desktop.
Save pfuntner/cdf1e734371cafe904f78b6b836347e4 to your computer and use it in GitHub Desktop.
json-shell test file
{
"bools": [true, false],
"ints": [42, 32768, -1],
"floats": [3.141592654, 2.7182818285, -0.000001],
"strs": ["a", "b", "foo", "bar"],
"none": null,
"dict": {
"1": [".", "one", "One", "ONE"],
"2": ["..", "two", "Two", "TWO"]
}
}
{
"level1": {
"level2": [
{
"var1": "value1"
},
{
"var2": "value2"
},
"value3",
{
"values": [
{
"var1": "Value1"
},
{
"var2": "Value2"
}
]
}
]
}
}
level1:
level2:
- var1: value1
- var2: value2
- value3
- values:
- var1: Value1
- var2: Value2
#! /usr/bin/env python
import sys
import json
import yaml
assert not sys.stdin.isatty(), 'You must redirect stdin'
json.dump(yaml.load(sys.stdin.read(), Loader=yaml.BaseLoader), fp=sys.stdout, indent=2)
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment