Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: put-value #2

Open
kseistrup opened this issue Apr 28, 2013 · 4 comments
Open

Idea: put-value #2

kseistrup opened this issue Apr 28, 2013 · 4 comments
Labels

Comments

@kseistrup
Copy link

Would it be possible to create a version of shyaml/shjson that manipulated key-value pairs? E.g.:

$ echo '{"a": 1, "b": 2}' | shjson put-value c 3
{
  "a": 1,
  "b": 2,
  "c": 3
}

or

$ echo '{"a": 1, "b": 2}' | shjson put-value b 7
{
  "a": 1,
  "b": 7
}

?

@vaab
Copy link
Member

vaab commented Apr 30, 2013

Yup, good idea. Will have to specify types also, and limit it to simples types at first. If you have some proposition to enter/build complex types (struct or list) thanks to the command line, I'm open ;)

@vaab
Copy link
Member

vaab commented Jan 3, 2015

Here's a quick thought on this topic. Nothing really valuable, I'm throwing ideas here in case.

To answer my own question, the way to enter complex types thanks to the command line could be... in shjson itself.

$ cat <<EOF | shjson put-value b.x '{"u": 1, "v": 2}'
{
    "a": [1, "foo"],
    "b": {"x": 1, "y": 2},
    "c": 3
}
EOF
{
    "a": [1, "foo"],
    "b": {"x": {"u": 1, "v": 2},
          "y": 2},
    "c": 3
}

For literal values you would need to double-quote though:

$ ...  | shjson put-value b.x '"my string"'

@charles-dyfis-net
Copy link

I'm tempted to take queues from jq here (assuming everything to be a string, but providing functions to cast/interpret to other types).

@vaab vaab added the idea label Sep 27, 2015
@ssbarnea
Copy link

Good idea, just name it "set" instead of "put". Everyone is using get/set, less HTTP but that's a very different case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants