JSON array without a named tag

Discussions relating to the ScottKlement.com port of the open source YAJL JSON Reader/Generator. This includes the YAJL tool as well as the YAJLR4, YAJLGEN, YAJLINTO and YAJLDTAGEN add-ons from ScottKlement.com. http://www.scottklement.com/yajl/
Post Reply
AddiedePinho
Posts: 2
Joined: Tue May 28, 2024 4:01 pm

JSON array without a named tag

Post by AddiedePinho »

The JSON received does not have a named tag for the arrays "properties"

there are no key value pairs in the properties list.
How do i need to setup my data structure to handle this?


this is the input (oRestExp.Response)

Code: Select all

{
    "id": "6655d1976079af00011c931b",
    "isBankAccountValid": true,
    "bankAccount": {
        "failedValidations": [],
        "properties": [
            "ACCOUNT_ACCEPTS_CREDITS",
            "ACCOUNT_ACCEPTS_DEBITS",
            "ACCOUNT_OLDER_THAN_THREE_MONTHS"
        ]
    },
    "bankAccountHolder": {
        "failedValidations": [
            "FAMILY_NAME_MISMATCH"
        ]
    }
}

Code: Select all

dcl-ds VerifyResponse  qualified;             
   id                    char(100);           
   isBankAccountValid    ind;                 
   dcl-ds bankAccount;                        
      num_failedValidations  int(10);         
      dcl-ds  failedValidations  dim(10);     
      end-ds;                                 
      num_properties        int(10);          
      dcl-ds properties  dim(10);             
      end-ds;                                 
   end-ds;                                    
   dcl-ds bankAccountHolder;                  
      num_failedValidations int(10);          
      dcl-ds failedValidations  dim(10);      
      end-ds;                                 
   end-ds;                                    
end-ds;      

data-into VerifyResponse %DATA(oRestExp.Response:     
                  'case=convert +                     
                  allowmissing=yes +                  
                  allowextra=yes +                    
                  countprefix=num_')                  
                  %PARSER('YAJLINTO');                   


the output VerifyResponse:
VERIFYRESPONSE.ID =
....5...10...15...20...25...30...35...40...45...50...55...60
1 '6655d1976079af00011c931b '
61 ' '
VERIFYRESPONSE.ISBANKACCOUNTVALID = '1'
VERIFYRESPONSE.BANKACCOUNT.NUM_FAILEDVALIDATIONS = 1077952576
VERIFYRESPONSE.BANKACCOUNT.FAILEDVALIDATIONS(1) = ' '
VERIFYRESPONSE.BANKACCOUNT.FAILEDVALIDATIONS(2) = ' '
VERIFYRESPONSE.BANKACCOUNT.FAILEDVALIDATIONS(3) = ' '
VERIFYRESPONSE.BANKACCOUNT.FAILEDVALIDATIONS(4) = ' '
VERIFYRESPONSE.BANKACCOUNT.FAILEDVALIDATIONS(5) = ' '
VERIFYRESPONSE.BANKACCOUNT.FAILEDVALIDATIONS(6) = ' '
VERIFYRESPONSE.BANKACCOUNT.FAILEDVALIDATIONS(7) = ' '
VERIFYRESPONSE.BANKACCOUNT.FAILEDVALIDATIONS(8) = ' '
VERIFYRESPONSE.BANKACCOUNT.FAILEDVALIDATIONS(9) = ' '
VERIFYRESPONSE.BANKACCOUNT.FAILEDVALIDATIONS(10) = ' '
VERIFYRESPONSE.BANKACCOUNT.NUM_PROPERTIES = 1077952576
VERIFYRESPONSE.BANKACCOUNT.PROPERTIES(1) = ' '
VERIFYRESPONSE.BANKACCOUNT.PROPERTIES(2) = ' '
VERIFYRESPONSE.BANKACCOUNT.PROPERTIES(3) = ' '
VERIFYRESPONSE.BANKACCOUNT.PROPERTIES(4) = ' '
VERIFYRESPONSE.BANKACCOUNT.PROPERTIES(5) = ' '
VERIFYRESPONSE.BANKACCOUNT.PROPERTIES(6) = ' '
VERIFYRESPONSE.BANKACCOUNT.PROPERTIES(7) = ' '
VERIFYRESPONSE.BANKACCOUNT.PROPERTIES(8) = ' '
VERIFYRESPONSE.BANKACCOUNT.PROPERTIES(9) = ' '
VERIFYRESPONSE.BANKACCOUNT.PROPERTIES(10) = ' '
VERIFYRESPONSE.BANKACCOUNTHOLDER.NUM_FAILEDVALIDATIONS = 1077952576
VERIFYRESPONSE.BANKACCOUNTHOLDER.FAILEDVALIDATIONS(1) = ' '
VERIFYRESPONSE.BANKACCOUNTHOLDER.FAILEDVALIDATIONS(2) = ' '
VERIFYRESPONSE.BANKACCOUNTHOLDER.FAILEDVALIDATIONS(3) = ' '
VERIFYRESPONSE.BANKACCOUNTHOLDER.FAILEDVALIDATIONS(4) = ' '
VERIFYRESPONSE.BANKACCOUNTHOLDER.FAILEDVALIDATIONS(5) = ' '
VERIFYRESPONSE.BANKACCOUNTHOLDER.FAILEDVALIDATIONS(6) = ' '
VERIFYRESPONSE.BANKACCOUNTHOLDER.FAILEDVALIDATIONS(7) = ' '
VERIFYRESPONSE.BANKACCOUNTHOLDER.FAILEDVALIDATIONS(8) = ' '
VERIFYRESPONSE.BANKACCOUNTHOLDER.FAILEDVALIDATIONS(9) = ' '
VERIFYRESPONSE.BANKACCOUNTHOLDER.FAILEDVALIDATIONS(10) = ' '
jonboy49
Posts: 244
Joined: Wed Jul 28, 2021 8:18 pm

Re: JSON array without a named tag

Post by jonboy49 »

Don't have time to play with this - supposed to be on vacation ...

At first glance "properties" should just be an array not a DS.

So this:

Code: Select all

     num_properties        int(10);          
     properties   varchar(50)   dim(10);    
Scott Klement
Site Admin
Posts: 872
Joined: Sun Jul 04, 2021 5:12 am

Re: JSON array without a named tag

Post by Scott Klement »

both properties and failedValidations should be arrays of character strings, not arrays of data structures.
AddiedePinho
Posts: 2
Joined: Tue May 28, 2024 4:01 pm

Re: JSON array without a named tag

Post by AddiedePinho »

Thank you for the reply.
I made the change, and it works
Post Reply