Conversation
|
Hi @0x04C2 I'm a little worried that Takes these two payloads for example: {"id":100, "first_name":null}{"id":100}Your version of With the current version of GJSON a user can use: p := gjson.Get(json,"first_name")
if p.Type == gjson.Null {
// ... true for both cases
}
if p.Type == gjson.Null && p.Exists() {
// ... true only for first case
}I can totally see how one user might desire the first condition as the behavior for I'm inclined to steering clear from an IsNull for now, but I happy to hear further feedback. |
|
Hi @tidwall , sorry for the delay reply. Basically, I just want to add API to help user to check the null value. Yes. I agree with you. For the second case you mentioned, the users maybe think that During using gjson, I like that there are very simple, powerful and easy-to-remember APIs. If there are more and more users which think there is no confusion, we can reconsider it. :) |
|
Maybe naming |
|
@0x04C2 I'm closing this PR for now. I don't think this change is necessary at this time. Thanks for the feedback on this issue. |
|
It makes sense. Thanks |
Hi @tidwall
json allows nullable value in body so that we can't use
Existsmethod for this case.For now, we can use
p.Type == gjson.Nullto check the value is NULL. In HTTP PATCH method, it's very common case in implementation. So, could we make it graceful by providing helperIsNulllikeIsArray? Does it make senses to you?