|
|
@ -31,7 +31,7 @@ Pretty print JSON without passing any arguments:
|
|
|
|
```
|
|
|
|
```
|
|
|
|
$ echo '{"key":"value"}' | fx
|
|
|
|
$ echo '{"key":"value"}' | fx
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"key": "value"
|
|
|
|
key: "value"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
@ -72,17 +72,17 @@ Access to JSON through `this` keyword:
|
|
|
|
```
|
|
|
|
```
|
|
|
|
$ echo '["a", "b"]' | fx 'yield* this'
|
|
|
|
$ echo '["a", "b"]' | fx 'yield* this'
|
|
|
|
[
|
|
|
|
[
|
|
|
|
"a",
|
|
|
|
"a",
|
|
|
|
"b"
|
|
|
|
"b"
|
|
|
|
]
|
|
|
|
]
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
$ echo '["a", "b"]' | fx 'yield* this; yield "c";'
|
|
|
|
$ echo '["a", "b"]' | fx 'yield* this; yield "c";'
|
|
|
|
[
|
|
|
|
[
|
|
|
|
"a",
|
|
|
|
"a",
|
|
|
|
"b",
|
|
|
|
"b",
|
|
|
|
"c"
|
|
|
|
"c"
|
|
|
|
]
|
|
|
|
]
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
@ -93,7 +93,7 @@ You can update existing JSON using spread operator:
|
|
|
|
```
|
|
|
|
```
|
|
|
|
$ echo '{"count": 0}' | fx '{...this, count: 1}'
|
|
|
|
$ echo '{"count": 0}' | fx '{...this, count: 1}'
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"count": 1
|
|
|
|
count: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
@ -125,8 +125,8 @@ Convert object to array:
|
|
|
|
```
|
|
|
|
```
|
|
|
|
$ cat package.json | fx 'Object.keys(this.dependencies)'
|
|
|
|
$ cat package.json | fx 'Object.keys(this.dependencies)'
|
|
|
|
[
|
|
|
|
[
|
|
|
|
"cardinal",
|
|
|
|
|
|
|
|
"get-stdin",
|
|
|
|
"get-stdin",
|
|
|
|
|
|
|
|
"jsome",
|
|
|
|
"meow"
|
|
|
|
"meow"
|
|
|
|
]
|
|
|
|
]
|
|
|
|
```
|
|
|
|
```
|
|
|
|