[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ftpapi] YAJL and format of numbers



That is the rule for JSON.  Leading zero is required.

Have you got  DECEDIT('0.') on your Ctl-Opt?  I have to use that with DATA-GEN using YAJLGEN to ensure that %Char (used under the covers) provides the leading zero.


Jon

On Mar 16, 2021, at 5:38 PM, Dean Eshleman <Dean.Eshleman@xxxxxxxxxxxx> wrote:

We have a REST service that uses YAJL to create the JSON for the response.  It is being called internally by a .NET application.  One of the fields is a 5p2 number.  Currently, we are using %char on that field to pass it to the yajl_addnum sub-procedure.  When the value is 0, what ends up in the JSON is .00.  This was okay until they tried to upgrade the .NET application and the new version of the JSON parser they are using from Newtonsoft doesn’t like that value for a number.  This was fixed going from version 9 to 10 of Newtonsoft (See https://github.com/JamesNK/Newtonsoft.Json/issues/1510 for a discussion on the issue) and now it requires 0.00 in the JSON for a zero value.
 
So, I downloaded the latest version of YAJL since I saw that there was a new sub-procedure called yajl_addnumf.  However, from looking at the source code for that sub-procedure I don’t think it will give me 0.00 for a zero value.  I copied the one statement “valf = %trimr(%trimr(%char(val):'0'):'.');” into another program to see what it gives me for a zero value.  It gives me a blank unless I’m doing something wrong.
 
From my testing, we could use %editw against our number and continue to use yajl_addnum to get around the problem for now.  I’m just wondering if this needs to be fixed in YAJL or is Newtonsoft making their own rules about JSON and numbers?
 
Dean Eshleman
Software Development Architect
Everence
 
1110 North Main Street
PO Box 483
Goshen, IN 46527
(800) 348-7468 ext. 3528
(574) 533-9515 ext. 3528
 
 


Disclaimer

This information is intended only for the individual or entity named. If you are not the intended recipient, do not use or disclose this information. If you received this e-mail in error, please delete or otherwise destroy it and contact us at (800) 348-7468 so we can take steps to avoid such transmission errors in the future. Thank you.

-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi

-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi