Lcd wrote:

>     Today I stumbled upon this article about JSON:
> 
>         http://seriot.ch/parsing_json.php
> 
>     The article links to a set of tests:
> 
>         https://github.com/nst/JSONTestSuite
> 
>     A quick run of the "y" and "n" tests against Vim's json_decode()
> finds a few problems.  Not particularly ground-breaking, but perhaps
> worth fixing:
> 
> * These should be accepted, but aren't:
> 
>         json_decode('{"a":"b","a":"c"}')    " E685
>         json_decode('{"a":"b","a":"b"}')    " E685

Those should not be internal errors.  But even though it's valid json,
the duplicate key is still an error.

>         json_decode('{"":0}')               " E474

Supporting an empty key has been reqeusted before.


> * These should be rejected, but aren't:
> 
>         json_decode('["",]')                " ['']
>         json_decode('[1,]')                 " [1]
>         json_decode('{1:1}')                " {'1': 1}
>         json_decode('{"id":0,}')            " {'id': 0}
>         json_decode('["\uD800\u"]')         " ['<d800>']
>         json_decode('["\uD800\u1"]')        " ['<d800><01>']
>         json_decode('["\uD800\u1x"]')       " ['<d800><01>x']
>         json_decode('["\x00"]')             " ['x00']
>         json_decode('["\a"]')               " ['a']
>         json_decode('[True]')               " [v:true]

Most are fine to accept.  The trailing \u seems wrong though.

> * There is even a segfault:
> 
>         json_decode(repeat('[', 100000))    " segfault

Probably running out of stack.  Would be difficult to fix, would need to
make the parsing iterative instead of recursive.

>     There are others, the above are just the main ones.  Also, for the
> "n" tests I was just checking that json_decode() rises an exception, not
> that the exception rised actually makes sense.

-- 
The problem with political jokes is that they get elected.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui