Maybe it is not clear but the rationale behind this is that a non existing field is semantically not the same as a null value.
-----Original Message-----
From: Paulo Lopes
Sent: 20/06/2013, 17:07
To:
ve...@googlegroups.com
Subject: Re: [vertx:9686] suggestion to extend the JsonObject API
Well on a java Map you can query for containsKey(keyName) which returns
true if it exists or not and if you call get(nonExistingKey) you get null.
What i am proposing is not implement the undefined concept, i am proposing
a way to verify if the field is present and that is not language specific
since the Map interface implements it too...
On Thursday, June 20, 2013 4:37:33 PM UTC+2, diega wrote:
>
> I'm not quite sure we should replicate language concepts patching an
> API. If Java doesn't have the notion of 'undefined' I see quite
> reasonable that you must go into the object definition to simulate
> your needs as you would do by checking the fieldNames set.
> Even if the hasField is added, how the default value on the
> get(String|Object|Array|Element|Boolean|Number|Long|Integer|Binary)
> methods should behave? should them throw an exception if some field is
> undefined? I think I see it way more confusing than just having to
> make the set inspection.
>
> My 2 μBTC
>
> On Thu, Jun 20, 2013 at 10:10 AM, Tim Yates <
tim....@gmail.com<javascript:>>
> wrote:
> > I agree it would make your code more readable, it's just you implied in
> your
> > original post that there was no way to do it in Java.
> >
> > And I don't think calling a public method on a public class is a case of
> > having to know the implementation details
> >
> >
> > On 20 June 2013 14:07, Paulo Lopes <
pml...@gmail.com <javascript:>>
> wrote:
> >>
> >> Yes i could but why do i would need to go to the implementation details
> of
> >> the json object in order to determine if a field is present or not?
> >>
> >> That is the way i am using it but I think that there is no need to know
> >> the implementation details of the json object class and having a
> fieldExists
> >> method would make code more readable...
> >>
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "vert.x" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an
> > email to
vertx+un...@googlegroups.com <javascript:>.
--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/vertx/mWkOomCJblI/unsubscribe.
To unsubscribe from this group and all of its topics, send an email to
vertx+un...@googlegroups.com.