Skip to content

Getting issue in the length property of JSONPATH #21

@RiteshKo

Description

@RiteshKo

Below is my json string

[{"Id":1,"Name":"first value","Added":"2022-06-15T09:48:36.7132436Z"},{"Id":2,"Name":"second value","Added":"2022-06-15T09:48:36.7132479Z"},{"Id":3,"Name":"third value","Added":"2022-06-15T09:48:36.713248Z"}]

And the structure is:

public class Data
{
    public int Id { get; set; }
    public string Name { get; set; }
    public DateTime Added { get; set; }
}

In the redis, I have one key for which I am storing List.
In case to insert a single data record I was using length to store new data record and was using JSONPATH.

Below is the JSONPATH
var serializedRedisData = JsonConvert.SerializeObject(data);
_database.JsonSet(redisKey, serializedRedisData, ".[(@.length)]");

But getting below error:

StackExchange.Redis.RedisServerException: 'JSON Path error: path error: \n$.[(@.length)]\n^^^^^\n'

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions