0
Votes
Undo
  1. Moshe Tangi
  2. PowerBuilder
  3. Thursday, 1 October 2020 09:27 AM UTC

Hi all

I am trying to generate a json string like this ( pb 2017 r3 ) :

{"shovarim":[{"SystemCode":1865,"MisparShovar":186500134,"LastDateToPayTime":"0001-01-01T00:00:00","SugShovar":32,"CodeUser":1200,"Herot":null,"ProgramCreate":9,"SumToPay":2.0,"ShurotShovar":[{"Subsystem":1865,"IdentityType":1,"IdentityNum":"201561834","TransactionPropertyType":0,"Sum":2.0,"SibatShura":null,"StartDatePayment":null,"EndtDatePayment":null,"SeifTaktzivi":null,"TatSeifTaktzivi":null,"TaarichShlifa":null,"IsGvia":null}],"DateBnia":"0001-01-01T00:00:00"}]}

It's  a array within array  ( the values are constat here and replaced in code )

Here is my code :

lnv_JsonGenerator = Create JsonGenerator

// Create an object root item
ll_RootObject = lnv_JsonGenerator.CreateJsonObject()

if ll_RootObject <> -1 then

// Add an array child item - shovarim
ll_ChildArray = lnv_JsonGenerator.AddItemArray(ll_RootObject , "shovarim")

The problem is this : 

lnv_JsonGenerator.AddItemNumber(ll_ChildArray, 'SystemCode' , SystemCode) - Not working !!

lnv_JsonGenerator.AddItemNumber(ll_ChildArray,  SystemCode) - Works !!

Why is that ? 

I can't write the name of the array child in the AddItemNumber ?

please help 

thanks

René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 1 October 2020 10:13 AM UTC
  2. PowerBuilder
  3. # 1

Hi Moshe,

I think you have to add an "object" to your array and than add your key/value pairs to the object.

See examples for GetItemObject function: https://docs.appeon.com/pb2019/powerscript_reference/ch10s16.html

HTH,

René

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.