Skip to content

Setting null as array value #25

Closed
Closed

Description

@mtharrison

I was expecting to be able to set null as an array item. Instead it sets the item to undefined:

var obj = { foo: 1, bar: { baz: 2}, qux: [3, 4, 5]};
jsonpointer.set(obj, '/qux/1', null);

{ foo: 1, bar: { baz: 2 }, qux: [ 3, , 5 ] }       // result
{ foo: 1, bar: { baz: 2 }, qux: [ 3, null, 5 ] }   // expected

Is this the intended behaviour?

Activity

  1. marcbachmann commented on Apr 13, 2016

    @marcbachmann
    Collaborator

    I think that's something not defined in the spec.
    So as long as there is no test test for it, we didn't specify that behavior.

    IMO it's not the right behavior. null is a valid value.

  2. marcbachmann commented on Apr 13, 2016

    @marcbachmann
    Collaborator

    There's an open pr that might fix it.
    Which I didn't merge yet because there are not enough tests. 😅
    I think I've fixed some things in there.

  3. mtharrison commented on Apr 13, 2016

    @mtharrison
    ContributorAuthor

    I tried with your branch performance-improvements and the behaviour is the same. If you're open to changing it, I'd be happy to take a stab at a PR?

  4. marcbachmann commented on Apr 13, 2016

    @marcbachmann
    Collaborator

    Ok. that line is the problem: https://github.com/marcbachmann/node-jsonpointer/blob/performance-improvements/jsonpointer.js#L42

    I think I didn't change that because I didn't want to change the behavior.
    We can change that but it needs a major version bump.
    Sure, I'd accept a pr. Can you build on mine and review it at the same time? 😁

  5. mtharrison commented on Apr 15, 2016

    @mtharrison
    ContributorAuthor

    Sure, give me a few days and I'll look into it 😄

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions