Skip to content

Can find element with #32

@Truemedia

Description

@Truemedia

Hi,
Sorry I left an issue before without a response due to dealing with other projects, but after playing around with this library more I can verify the problem.

I am trying to move one piece of JSON to another location in the same doc. While this has been working for the most part one particular operation seems to fail.

See the following:

[ { op: 'move',
    from: '/14',
    path: '/250/nested_classes/0/nested_classes/' } ]

I am performing this on a variable called doc.

If I do the following:
console.log(doc[250]['nested_classes'][0]['nested_classes']);

I get square brackets because that is an array, which is fine that's what I want and I just want to insert the moved data into that array so that it becomes the first item.

The data from this:
console.log(doc[14]);

I get:

{ class_name: 'CreditCard',
  sub_class: 'PaymentMethod',
  properties: {},
  nested_classes: [] }

I have used this same logic for an existing node in my doc and it works completely fine, but I have no idea why it does not work in this scenario when I can see both paths exist.

Is this some kind of hard to find bug in the library, or some issue with how my paths have been typed?

Really appreciate any help with this, thanks.

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