Write-Json On Dataset and Temp-table Omits logical fields w

Posted by olehansen on 11-Jan-2019 10:56

HI All.

I have a Pasoe rest API where in one of the request the response is a temp-table defined in a dataset  with among others one logical field.

When this field has the value "true" the field comes out ok in the response Json, but when it is set to false, the field disapears from the response json and is not shown.

Why is that?

I am using write-json on dataset for the output.

dataset dsResponse:WRITE-JSON ("longchar", oinvoice,FALSE,"UTF-8",YES,YES).

Any response would be appreciated.

Verion in use is Openendge 11.7.3

Posted by Mike Fechner on 11-Jan-2019 12:09

Your second "YES" instructs the WRITE-JSON to skip values that match the initial value.

Posted by bronco on 11-Jan-2019 12:12

The first "YES" is the omit-initial-values parameters. Since false is the initial value it is omitted.

All Replies

Posted by Mike Fechner on 11-Jan-2019 12:09

Your second "YES" instructs the WRITE-JSON to skip values that match the initial value.

Posted by bronco on 11-Jan-2019 12:12

The first "YES" is the omit-initial-values parameters. Since false is the initial value it is omitted.

Posted by Stefan Drissen on 11-Jan-2019 12:16

And if you wish to continue omitting the initial value - define the temp-table field initial value as unknown (?), both true and false will then be written.

Posted by bronco on 11-Jan-2019 12:23

WRITE-JSON ( target-type

 , { file | stream | stream-handle | memptr | longchar

       | JsonArray | JsonObject }

 [ , formatted [ , encoding [ , omit-initial-values  

 [ , omit-outer-object [ , write-before-image ] ] ] ] ] )

Posted by olehansen on 11-Jan-2019 15:07

aha Of course, my bad.! In other words , read the docs. Sorry, only my second week with progress abl.

This thread is closed