You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Jan Šmucr <Ja...@aimtecglobal.com> on 2022/11/23 13:00:03 UTC

JsonUtil.truncate() unexpected behavior

Hello.

I’ve been using the Message.toPropertyMap() function and recently I’ve discovered that it does not preserve null values, as they get replaced by an empty string in JsonUtil.truncate(). I understand that it’s not possible to put null values into maps, but on the other hand, they are supported in JSON and there’s quite a difference between null and "". And the toPropertyMap function doc states clearly: “…useful when encoding to JSON”.

Is this an expected behavior? I can work around that, but should I?

Jan


Re: JsonUtil.truncate() unexpected behavior

Posted by Justin Bertram <jb...@apache.org>.
As Robbie noted, this is expected. However, that doesn't mean it has to be
that way. If you think it should be changed please open a Jira and outline
a use-case where nulls make sense and empty strings don't.


Justin

On Wed, Nov 23, 2022 at 7:44 AM Robbie Gemmell <ro...@gmail.com>
wrote:

> I guess its expected in so far as it was done deliberately:
> https://github.com/apache/activemq-artemis/pull/3948
>
>
> On Wed, 23 Nov 2022 at 13:01, Jan Šmucr <Ja...@aimtecglobal.com>
> wrote:
> >
> > Hello.
> >
> > I’ve been using the Message.toPropertyMap() function and recently I’ve
> discovered that it does not preserve null values, as they get replaced by
> an empty string in JsonUtil.truncate(). I understand that it’s not possible
> to put null values into maps, but on the other hand, they are supported in
> JSON and there’s quite a difference between null and "". And the
> toPropertyMap function doc states clearly: “…useful when encoding to JSON”.
> >
> > Is this an expected behavior? I can work around that, but should I?
> >
> > Jan
> >
>
>

Re: JsonUtil.truncate() unexpected behavior

Posted by Robbie Gemmell <ro...@gmail.com>.
I guess its expected in so far as it was done deliberately:
https://github.com/apache/activemq-artemis/pull/3948


On Wed, 23 Nov 2022 at 13:01, Jan Šmucr <Ja...@aimtecglobal.com> wrote:
>
> Hello.
>
> I’ve been using the Message.toPropertyMap() function and recently I’ve discovered that it does not preserve null values, as they get replaced by an empty string in JsonUtil.truncate(). I understand that it’s not possible to put null values into maps, but on the other hand, they are supported in JSON and there’s quite a difference between null and "". And the toPropertyMap function doc states clearly: “…useful when encoding to JSON”.
>
> Is this an expected behavior? I can work around that, but should I?
>
> Jan
>