Skip to content

Add MaxDepth to JsonWriterOptions #44947

Closed

Description

@amosonn

Background and Motivation

Whereas JsonReaderOptions has MaxDepth property, JsonWriterOptions does not, instead taking a constant. While this constant is quite large (1000, compared to the default 64 on reading), there is no easy way to work with larger depths.

Even worse, JsonSerializerOptions has a MaxDepth property, but is not respected on Serialize, as there is no way to pass it on to the JsonWriter.

Proposed API

Add a JsonWriterOptions.MaxDepth property; set that property when called from JsonSerializer.

namespace System.Text.Json
{
    public partial struct JsonWriterOptions
    {
        public bool MaxDepth { get; set; }
    }
}

Alternative Designs

The current API, where this is a constant. This decision is described in #27938 , but I couldn't see a rationale.

Activity

  1. added
    api-suggestionEarly API idea and discussion, it is NOT ready for implementation
    on Nov 19, 2020
  2. changed the title [-]MaxDepth to JsonWriterOptions[/-] [+]Add MaxDepth to JsonWriterOptions[/+] on Nov 19, 2020
  3. added this to the Future milestone on Nov 25, 2020
  4. added
    needs-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration
    and removed
    untriagedNew issue has not been triaged by the area owner
    on Nov 25, 2020
  5. added
    untriagedNew issue has not been triaged by the area owner
    and removed
    needs-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration
    on Apr 19, 2021
  6. removed
    untriagedNew issue has not been triaged by the area owner
    on Jul 8, 2021
  7. modified the milestones: Future, 7.0.0 on Oct 15, 2021
  8. added
    api-needs-workAPI needs work before it is approved, it is NOT ready for implementation
    on Oct 15, 2021
  9. added
    api-ready-for-reviewAPI is ready for review, it is NOT ready for implementation
    and removed
    api-needs-workAPI needs work before it is approved, it is NOT ready for implementation
    on Oct 29, 2021
  10. eiriktsarpalis commented on Oct 29, 2021

    @eiriktsarpalis
    Member

    I've updated the API proposal and marked it ready for review.

  11. terrajobst commented on Nov 2, 2021

    @terrajobst
    Contributor

    Video

    • Looks good as proposed
    namespace System.Text.Json
    {
        public partial struct JsonWriterOptions
        {
            public int MaxDepth { get; set; }
        }
    }
  12. added
    api-approvedAPI was approved in API review, it can be implemented
    and removed
    api-ready-for-reviewAPI is ready for review, it is NOT ready for implementation
    on Nov 2, 2021
  13. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Nov 15, 2021
  14. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Nov 22, 2021
  15. ghost locked as resolved and limited conversation to collaborators on Dec 23, 2021
  16. added
    User StoryA single user-facing feature. Can be grouped under an epic.
    Cost:SWork that requires one engineer up to 1 week
    on Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Cost:SWork that requires one engineer up to 1 weekTeam:LibrariesUser StoryA single user-facing feature. Can be grouped under an epic.api-approvedAPI was approved in API review, it can be implementedapi-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Text.Json

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions