2017-01-28 6:23 GMT+03:00 David Fishburn <dfishburn....@gmail.com>:
> On Fri, Jan 27, 2017 at 8:42 PM, Nikolay Aleksandrovich Pavlov
> <zyx....@gmail.com> wrote:
>>
>> 2017-01-28 4:33 GMT+03:00 David Fishburn <dfishburn....@gmail.com>:
>> > Running on Windows using:
>> >
>> > :ver
>> > VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan 24 2017 13:37:57)
>> > MS-Windows 32-bit GUI version with OLE support
>> > Included patches: 1-233
>> >
>> > job_info(...) returned the following:
>> >
>> > {
>> > 'status': 'run',
>> > 'stoponexit': 'term',
>> > 'exitval': 0,
>> > 'exit_cb': 0,
>> > 'channel': channel 0 open,
>> > 'process': 10912
>> > }
>> >
>> > This should be in quotes:
>> > channel 0 open
>>
>> It should not, it is not a string. What are you trying to do?
>>
>
> I was trying to get access to "exitval" and thought I could do it with the
> new json stuff.
>
> So I was experimenting:
>
>
>>echo job_info(s:dbext_job)
> {'status': 'run', 'stoponexit': 'term', 'exitval': 0, 'exit_cb': 0,
> 'channel': channel 1 open, 'process': 3524}
>
>>echo json_decode(job_info(s:dbext_job))
> Error detected while processing function <SNR>83_DB_runCmdJobUpdateStatus:
> line    1:
> E731: using Dictionary as a String

This is pretty much descriptive. `json_decode` decodes *JSON*
**string**. You are trying to supply a dictionary. `:echo` is useful
for printing various values, though you can’t distinguish `:echo '{}'`
(string with dictionary representation) and `:echo {}` (actualy
dictionary), `:h job_info()` explicitly states what type it returns if
error message is not enough.

You don’t need to decode anything, you *already* have a dictionary. Do
with it just what you wanted to do with `json_decode()` output, e.g.
index it (`let exitval = job_info(s:dbext_job).exitval`).

// And, BTW, `'single quoted string'` is not a valid JSON. If
`json_decode("'single quoted string'")` happened to work, it would be
a bug. JSON only supports double quotes.

> v:none
>
>>echo string(json_decode(job_info(s:dbext_job)))
> E731: using Dictionary as a String
> v:none
>
> Thought it might have been happening due to invalid JSON.
>
> Thanks for your response.
> David
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui