[tarantool-patches] Re: [PATCH] json: clarify bad syntax error messages

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Fri Sep 27 22:54:48 MSK 2019


Hi! Thanks for the patch!

> diff --git a/third_party/lua-cjson/lua_cjson.c b/third_party/lua-cjson/lua_cjson.c
> index 6b03e391a..0dee2deb9 100644
> --- a/third_party/lua-cjson/lua_cjson.c
> +++ b/third_party/lua-cjson/lua_cjson.c
> @@ -105,11 +107,12 @@ typedef struct {
>      strbuf_t *tmp;    /* Temporary storage for strings */
>      struct luaL_serializer *cfg;
>      int current_depth;
> +    int line_count;
> +    const char *cur_line_ptr;
>  } json_parse_t;
>  
>  typedef struct {
>      json_token_type_t type;
> -    int index;

Unfortunately, you can't remove token index. Otherwise
error messages will report wrong positions:

tarantool> json.decode("{ 100: 200 }")
---
- error: Expected object key string but found T_INT on line 1 at character 6
...

Error was on character 3 (begin of '100'), not 6.




More information about the Tarantool-patches mailing list