Skip to content

Get (valid!) JsonPath or JsonPointer from a JsonNode #406

@amis92

Description

@amis92

Environment

  • Nuget Package: JsonPath.Net
  • Nuget Version: 0.4.0
  • OS: dotnetFiddle/Linux
  • .Net Target:

Can this library make doing something simpler?

I'd like to be able to generate a correct JSON Path and/or JSON Pointer from a System.Text.Json.Nodes.JsonNode type.

Describe alternatives you've considered

Post a bug report to dotnet/runtime.

Additional context

Json path generated by BCL's JsonNode.GetPath() for a property like $id is invalid and fails to be parsed by JsonPath.

I'd like to have some (extension?) methods that provide a valid JsonPath and JsonPointer given a JsonNode. It seems to already be mostly done within the code of this library, but is not available via public API. It can return a plain string, or a strongly typed parsed instance of path or pointer.

A dotnet fiddle to illustrate the issue: https://dotnetfiddle.net/vkcQQ8

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions