Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Cc: tarantool-patches@freelists.org, kostja@tarantool.org
Subject: Re: [PATCH v6 4/4] lib: introduce json_path_cmp, json_path_validate
Date: Mon, 10 Dec 2018 20:38:00 +0300	[thread overview]
Message-ID: <20181210173800.2eehyutqzcm5kt2j@esperanza> (raw)
In-Reply-To: <7e8a84a863de29269e0731f3dcff2df90ed6813e.1544084229.git.kshcherbatov@tarantool.org>

On Thu, Dec 06, 2018 at 11:42:31AM +0300, Kirill Shcherbatov wrote:
> Introduced json_path_validate routine to ensure user-defined
> JSON path is valid. This will be required to raise an error if
> an incorrect user-defined jason-path is detected.
> 
> Introduced json_path_cmp routine to compare JSON paths that may
> have different representation.
> Note that:
>  - in case of paths that have same token-sequence prefix,
>    the path having more tokens is assumed to be greater
>  - both paths to compare should be valid
> 
> Needed for #1012

> +/**
> + * Check if the passed JSON path is valid.
> + * Return 0 for valid path and error position for invalid.
> + */
> +static inline int
> +json_path_validate(const char *path, uint32_t path_len, uint32_t index_base)
> +{
> +	struct json_lexer lexer;
> +	json_lexer_create(&lexer, path, path_len, index_base);
> +	struct json_token token;
> +	int rc;
> +	while ((rc = json_lexer_next_token(&lexer, &token)) == 0 &&
> +		token.type != JSON_TOKEN_END) {};
> +	return rc;
> +}

No need to define this function in the header. I moved it to json.c and
pushed the patch to 2.1.

      reply	other threads:[~2018-12-10 17:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06  8:42 [PATCH v6 0/4] box: JSON tree class Kirill Shcherbatov
2018-12-06  8:42 ` [PATCH v6 1/4] lib: make index_base support for json_lexer Kirill Shcherbatov
2018-12-10 17:34   ` Vladimir Davydov
2018-12-06  8:42 ` [PATCH v6 2/4] lib: implement JSON tree class for json library Kirill Shcherbatov
2018-12-10 17:36   ` Vladimir Davydov
2018-12-06  8:42 ` [PATCH v6 3/4] box: manage format fields with JSON tree class Kirill Shcherbatov
2018-12-11  9:52   ` Vladimir Davydov
2018-12-06  8:42 ` [PATCH v6 4/4] lib: introduce json_path_cmp, json_path_validate Kirill Shcherbatov
2018-12-10 17:38   ` Vladimir Davydov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181210173800.2eehyutqzcm5kt2j@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH v6 4/4] lib: introduce json_path_cmp, json_path_validate' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox