Skip to content

Null ignoring at SelectElements from System.Text.Json at JsonDocumentPathExtensions #78963

@Cubody

Description

@Cubody

Description

I was trying to parse json with null fields via jsonpath, but got empty array. I checked source code of library methods and didn't find there any option where I can set null handling.

Reproduction Steps

  1. Use this json:
const string featuresJson =
                @"{
                  ""files"": [
                    {
                      ""id"": ""90d1aeae-481b-4c82-821b-a034f9aa77cd"",
                      ""document_type"": null
                    }
                  ]
                }";
  1. Try to use json.SelectElements("$.files[*].document_type").Select(e => e.HasValue ? (object) e.Value : null);
  2. It will return empty array.

Expected behavior

We have option to include nulls in filter.

Actual behavior

We can't set excepted behaviour.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

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