Skip to content

LAST_INDEX serialization does not preserve RFC 6901 sentinel on round-trip #222

@coderabbitai

Description

@coderabbitai

Context

This issue tracks a pre-existing serialization concern with the LAST_INDEX constant identified during code review of PR #221.

Description

When LAST_INDEX (currently Integer.MIN_VALUE) is used in the append(int) method of AbstractJsonPointer (previously in JsonPointer), it creates a RefToken with the numeric string "-2147483648". Upon serialization via toString() and re-parsing:

  • The numeric string "-2147483648" does not match the VALID_ARRAY_IND regex pattern
  • The parser treats it as a property name instead of an array index sentinel
  • The semantic meaning (append-to-end) is lost in the round-trip

This affects the RFC 6901 compliance where "-" is the standard sentinel for array append operations.

Source

Identified in code review of PR #221 (Jackson 3 support):

Requested by: @sondemar

Location

The logic exists in:

  • src/main/java/com/flipkart/zjsonpatch/AbstractJsonPointer.java (lines 115-132 after PR Add Jackson 3 support #221)
  • Originally in src/main/java/com/flipkart/zjsonpatch/JsonPointer.java on master branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions