Skip to content

How can I replace the value if the key name is with a dot?  #159

@andrew-clear

Description

@andrew-clear

As I understand, I can replace value via this command:
json -I -f test.json -e "this.name='andrew'"
But how can I replace a value for this key -> last.name?
I mean when I try to replace the value via this command
json -I -f test.json -e "this.last.name='andrew'"
I got:

undefined:3
this.last.name='andrew'
              ^

TypeError: Cannot set properties of undefined (setting 'name')
    at Object.eval (eval at main (/usr/local/lib/node_modules/json/lib/json.js:1365:27), <anonymous>:3:15)
    at parseChunk (/usr/local/lib/node_modules/json/lib/json.js:1569:29)
    at /usr/local/lib/node_modules/json/lib/json.js:1426:13
    at getInput (/usr/local/lib/node_modules/json/lib/json.js:738:17)
    at main (/usr/local/lib/node_modules/json/lib/json.js:1396:9)
    at Object.<anonymous> (/usr/local/lib/node_modules/json/lib/json.js:1764:5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions