How to parse JSON passed on the command line?
Roy Smith
roy at panix.com
Wed Nov 6 23:12:27 EST 2013
In article <mailman.2117.1383796399.18130.python-list at python.org>,
Anthony Papillion <papillion at gmail.com> wrote:
> Hello Everyone,
>
> I'm writing a little helper script in Python that will access a JSON
> formatted argument from the shell when it's called. The parameter will
> look like this:
>
> {"url":"http://www.google.com"}
>
> So, if my program is called "getargfromcli.py" the call will look like this:
>
> getargfromcli.py {"url":"http://www.google.com"}
>
> In the case above, I assume my JSON string will be argv[1]. In fact,
> when I do
>
> print sys.argv[1]
>
> It works as expected and prints out the JSON string as expected like
> this: {url:http://www.google.com}
Which is not valid JSON. You lost the quotes. I suspect you want to
More information about the Python-list
mailing list