podhmo / dictknife

armyknife of handling dict object
MIT License
19 stars 4 forks source link

mkdict command? #52

Closed podhmo closed 6 years ago

podhmo commented 6 years ago
$ dictknife mkdict --name foo --age 20
{
  "name": "foo",
  "age": 20
}
podhmo commented 6 years ago
$ dictknife mkdict --name foo --age 20 --name bar
{
  "name": "bar",
  "age": 20
}

$ dictknife mkdict --name foo --age 20 ";" --name bar
[
  {
    "name": "foo",
    "age": 20
  },
  {
    "name": "bar"
  }
]

$ dictknife mkdict --squash --name foo --age 20 ";" --name bar
{
  "name": "foo",
  "age": 20
}
{
  "name": "bar"
}
podhmo commented 6 years ago
dictknife mkdict @ob/name foo @ob/age 40 name bar age 20 parent "&ob" ";" name boo age 18 parent "&ob" | tee output/09.json
[
  {
    "name": "bar",
    "age": 20,
    "parent": {
      "name": "foo",
      "age": 40
    }
  },
  {
    "name": "boo",
    "age": 18,
    "parent": {
      "name": "foo",
      "age": 40
    }
  }
]
podhmo commented 6 years ago
$  dictknife mkdict @xs//name a @xs/-1/age 20 @xs/1/name b @xs/1/age 10 names/ "&xs/0/name" names/ "&xs/1/name"
{
  "names": [
    "a",
    "b"
  ]
}