Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoding Issue #1

Closed
hdegroot opened this issue Apr 19, 2018 · 5 comments
Closed

Decoding Issue #1

hdegroot opened this issue Apr 19, 2018 · 5 comments

Comments

@hdegroot
Copy link

Hello Koemaeda!

I ran into an issue with decoding a JSON object using your great ZCL_JSON class. (Thank you so much for making that one available!!!)

My JSON object is like this:

{
"totalRecordCount": 1,
"aches": [{
"accountHolderTerminated": false,
"accountVerified": true,
"depositAmount1": null,
"depositAmount2": null,
"userCode": 0,
"accountingId": "les04",
"accountHolderEmailAddress": "Sean.Le@marcusmillichap.com",
"accountHolderFirstName": "Sean",
"accountHolderMiddleName": "M.",
"accountHolderLastName": "Le",
"accountHolderName": "Sean Le",
"accountNumber": "9xxxxx54321",
"accountType": "Checking",
"paymentType": "Commissions",
"bankName": "",
"confirmAccountNumber": "",
"routingNumber": "123xxx6789",
"userId": "sle4",
"accountTypeIndicator": "C",
"dateAdded": "2018-04-16T09:44:44.627",
"dateAccountVerified": "2018-04-16T00:00:00",
"finalTerminationDate": null
}]
}

"decode" parses the aches array in the JSON object correctly.
But for some reason unknown to me it doesn't parse the value for totalRecordCount. The value comes out as 0.

This is how I did define the corresponding type for the JSON object in SAP:

TYPES: BEGIN OF agent,
accountholderterminated TYPE string,
accountverified TYPE string,
depositamount1 TYPE string,
depositamount2 TYPE string,
usercode TYPE string,
accountingid TYPE string,
accountholderemailaddress TYPE string,
accountholderfirstname TYPE string,
accountholdermiddlename TYPE string,
accountholderlastname TYPE string,
accountholdername TYPE string,
accountnumber TYPE string,
accounttype TYPE string,
paymenttype TYPE string,
bankname TYPE string,
confirmaccountnumber TYPE string,
routingnumber TYPE string,
userid TYPE string,
accounttypeindicator TYPE string,
dateadded TYPE string,
dateaccountverified TYPE string,
END OF agent.

TYPES: BEGIN OF web_service,
         totalrecordcount TYPE i,
         aches TYPE TABLE OF agent WITH DEFAULT KEY,
       END OF web_service.
DATA: v_agent TYPE web_service.

Koemaeda, do you have any idea why? Again, the aches array does parse correctly; the only issues is with the totalRecordCound field.

Thank you very much for your time!

Best regards,

---Hugo

@koemaeda
Copy link
Owner

Hello Hugo!
Thanks for finding this! This class doesn't support integers (unquoted) yet.
I will implement it this week.

Best regards,
Koe

@hdegroot
Copy link
Author

Thanks, Koe!

@hdegroot
Copy link
Author

Hi Koe,
Noticed also boolean fields are not parsed (yet).
E.g., "accountHolderTerminated": false,
Would be cool if "true" values could be parsed to 'X' and "false" values to ' '.
Best,
---Hugo

@koemaeda
Copy link
Owner

koemaeda commented May 1, 2018

Sorry for taking so long!

I've added support for keywords (true, false and null) and numbers, according to the official JSON syntax (Number format incompatibilities might still happen as parsing will use the standard ABAP Conversion Exits.

As you suggested, boolean fields will be translated to the "flag" default: X for true and space for false.
Thanks for finding these.
Koe

@koemaeda koemaeda closed this as completed May 1, 2018
@hdegroot
Copy link
Author

hdegroot commented May 1, 2018

Thank you, Koe! I'll test it in our system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants