You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zeppelin.apache.org by 임정택 <ka...@gmail.com> on 2015/12/23 00:08:29 UTC

[DISCUSS] Preference of the JSON output representing null value

Hi devs,

It could be a tiny / trivial issue, but I'd love to see our opinions about
the JSON output.

When we use Map to body in JsonResponse (for REST API), it only represents
keys which have non-null value to JSON.
Please refer https://github.com/apache/incubator-zeppelin/pull/562

It seems to be Gson's behavior, optimization of the size of the JSON output.

If we prefer all fields to be represented, we can modify it easily. Please
refer here.
http://stackoverflow.com/questions/3923759/gson-ignoring-map-entries-with-value-null

All Json Responses will be affected, so I'd love to hear that we want null
objects or not.
Please share your opinions.

Thanks!
Jungtaek Lim (HeartSaVioR)

Re: [DISCUSS] Preference of the JSON output representing null value

Posted by Jungtaek Lim <ka...@gmail.com>.
Alexander,

Thanks for the input.
Yes, that's why Option or others comes in modern language.

Returning to origin issue, could you please take a look at PR #562 and
comment?
Seems like we can leave as it is, but PR #562 puts null value to the Map,
so you would also think "removing put null value to Map" would be more
appreciated.

Thanks!
Jungtaek Lim (HeartSaVioR)

On Wed, Dec 23, 2015 at 8:41 AM, Alexander Bezzubov <bz...@apache.org> wrote:

> Hi,
>
> having null values meaning checking for nulls everywhere, which by itself
> adds quite meaningless code all over the place.
>
> I would say mature programmung style is to avoid having nulls whenever
> possible, including serialization on disk/wire.
>
> Other thoughts about not having null:
>
> - "I call it my billion-dollar *mistake*. It was the invention of the
> *null* reference
> in 1965." https://en.m.wikipedia.org/wiki/Tony_Hoare
>
> - *"Null sucks."* -Doug Lea <http://en.wikipedia.org/wiki/Doug_Lea>
>
> - for more background/morivation of avoiding nulls please see
> https://github.com/google/guava/wiki/UsingAndAvoidingNullExplained
>
> If we ought to change something - I would suggest eliminating the code that
> puts nulls in the objects that should be serilaized.
>
> Hope this helps.
>
> On Wed, Dec 23, 2015, 08:08 임정택 <ka...@gmail.com> wrote:
>
> > Hi devs,
> >
> > It could be a tiny / trivial issue, but I'd love to see our opinions
> about
> > the JSON output.
> >
> > When we use Map to body in JsonResponse (for REST API), it only
> represents
> > keys which have non-null value to JSON.
> > Please refer https://github.com/apache/incubator-zeppelin/pull/562
> >
> > It seems to be Gson's behavior, optimization of the size of the JSON
> > output.
> >
> > If we prefer all fields to be represented, we can modify it easily.
> Please
> > refer here.
> >
> >
> http://stackoverflow.com/questions/3923759/gson-ignoring-map-entries-with-value-null
> >
> > All Json Responses will be affected, so I'd love to hear that we want
> null
> > objects or not.
> > Please share your opinions.
> >
> > Thanks!
> > Jungtaek Lim (HeartSaVioR)
> >
>



-- 
Name : Jungtaek Lim
Blog : http://medium.com/@heartsavior
Twitter : http://twitter.com/heartsavior
LinkedIn : http://www.linkedin.com/in/heartsavior

Re: [DISCUSS] Preference of the JSON output representing null value

Posted by Alexander Bezzubov <bz...@apache.org>.
Hi,

having null values meaning checking for nulls everywhere, which by itself
adds quite meaningless code all over the place.

I would say mature programmung style is to avoid having nulls whenever
possible, including serialization on disk/wire.

Other thoughts about not having null:

- "I call it my billion-dollar *mistake*. It was the invention of the
*null* reference
in 1965." https://en.m.wikipedia.org/wiki/Tony_Hoare

- *"Null sucks."* -Doug Lea <http://en.wikipedia.org/wiki/Doug_Lea>

- for more background/morivation of avoiding nulls please see
https://github.com/google/guava/wiki/UsingAndAvoidingNullExplained

If we ought to change something - I would suggest eliminating the code that
puts nulls in the objects that should be serilaized.

Hope this helps.

On Wed, Dec 23, 2015, 08:08 임정택 <ka...@gmail.com> wrote:

> Hi devs,
>
> It could be a tiny / trivial issue, but I'd love to see our opinions about
> the JSON output.
>
> When we use Map to body in JsonResponse (for REST API), it only represents
> keys which have non-null value to JSON.
> Please refer https://github.com/apache/incubator-zeppelin/pull/562
>
> It seems to be Gson's behavior, optimization of the size of the JSON
> output.
>
> If we prefer all fields to be represented, we can modify it easily. Please
> refer here.
>
> http://stackoverflow.com/questions/3923759/gson-ignoring-map-entries-with-value-null
>
> All Json Responses will be affected, so I'd love to hear that we want null
> objects or not.
> Please share your opinions.
>
> Thanks!
> Jungtaek Lim (HeartSaVioR)
>