Skip to content

Support array indices in JSON field paths #468

Open
@mariusoe

Description

@mariusoe

Hi,

when using a PayloadSubsectionExtractor (e.g. FieldPathPayloadSubsectionExtractor) to extract a subsection of a JSON payload, array indices are ignored.

I would assume that when a path is used like Outer[].Nested[0].Attribute only the first (in this example Nested) element or which is matching the specified index will match the given path and, thus, returned. But it extracts always all elements which results in a PayloadHandlingException({PATH} + " does not uniquely identify a subsection of the payload").

Activity

wilkinsona

wilkinsona commented on Jan 2, 2018

@wilkinsona
Member

That's working as (currently) designed. There's no support for array indices anywhere in REST Docs at the moment.

changed the title [-]PayloadSubsectionExtractor is ignoring array indices. [/-] [+]Support array indices in JSON field paths[/+] on Jan 2, 2018
dibog

dibog commented on May 11, 2020

@dibog

+1 from me for the enhancement request

florensie

florensie commented on Nov 4, 2024

@florensie

If it's not supported, it shouldn't be parsed either. Currently it's possible to use path.to.array[0] and the index will be ignored, creating confusing results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementEnhancement that adds a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @wilkinsona@dibog@mariusoe@florensie

        Issue actions

          Support array indices in JSON field paths · Issue #468 · spring-projects/spring-restdocs