kvrocks icon indicating copy to clipboard operation
kvrocks copied to clipboard

JSON: support basic legacy path

Open mapleFU opened this issue 2 years ago • 3 comments
trafficstars

RedisJson supports a JsonPath for legacy client [1]. This patch only support the basic JsonPath "."

Note: this patch doesn't means fully compatible with Json legacy path, it just try it best to convert to JsonPath. There're still some behaviors we cannot compatible with.

[1] https://redis.io/docs/data-types/json/path/#legacy-path-syntax

mapleFU avatar Oct 16 '23 05:10 mapleFU

Actually there are some difference in the query result between path $.x and .x (or x). It can be observe that query of path prefixed without $ will just get response with the first matched value instead of an array.

This patch is only a basic json legacy path support, the detail rule will be handled later.

mapleFU avatar Oct 16 '23 10:10 mapleFU

@PragmaTwice I've add a JsonPath type, however, currently I find the evaluation has a problem when we need support both const and mutable. Would you mind take a look?

mapleFU avatar Oct 16 '23 11:10 mapleFU

Note: this patch doesn't means fully compatible with Json legacy path, it just try it best to convert to JsonPath. There're still some behaviors we cannot compatible with.

I found that:

  1. Field name like $a is not support
  2. ['a'] or ["a"] is not so well support now

mapleFU avatar Oct 18 '23 16:10 mapleFU

Close as stale. @mapleFU welcome to pick up and rebase on a new patch.

tisonkun avatar Jul 02 '24 17:07 tisonkun