remy / jsonbin

A personal JSON store as a RESTful service
https://jsonbin.org
395 stars 26 forks source link

patch <property>:null doesn't remove a property itself #21

Closed srgg6701 closed 7 years ago

srgg6701 commented 7 years ago

I have such an object:

"blog": {
    "name": "srgg",
    "last name": "who knows",
    "moniker": {
      "first one": "Pierrot"
    }
  }

The following query:

$.ajax({
    headers: {
        authorization : "token <token>"
    },
    method: "patch",
    url: "https://jsonbin.org/<user_name>/blog",
    data: {"name":null}
});

... doesn't remove the property, but changes its value to the empty string: "name": ""

remy commented 7 years ago

Hmm. I just wrote an automation test (so it's easy to say "start with this, do this, expect this") and it's passing for your situation. I then tried again manually and it's passing.

Can you check your network requests to ensure that a) it's going up a application/json and b) the null prop isn't being stripped (though it shouldn't, AKAIK only undefined will be stripped).

See files called 21.*: https://github.com/remy/jsonbin/tree/master/tests/operations

remy commented 7 years ago

Going to close this, I'm pretty sure it's all good - the upshot: tests have been easier to contribute 😄