I am working on payment gateway project based on RESTful calls using
JSON objects. Now that I am heavy into debugging my application I came
across a few anomalies using the built-in JSON functions provided by
OBD. I was hoping someone else could either tell me I am crazy or
clarify why the functions work the way they do. Any help is greatly
appreciated.

First, I am relying on the function isJSON() to validate the POST data
the client is sending to our gateway. I found that this function will
always return "true" regardless of the string you pass the function.
So, "isJSON('fooBar')" returns true. I am not too sure this is what
should be happening. I would think at the least it should verify that
the string starts and ends with braces ({}). Any one else experience
this?

Next, I am also experiencing issues with the deserializeJSON()
function and I am not too sure if it is either a flaw in the
function's logic or a flaw in my expectations/logic. Specifically, one
of the values passed in the JSON object is the credit card number
(13-16 characters long with no dashes). Using the deserialize function
OBD handles this value as a number, irregardless of the double quotes
surrounding the value declaration (ex.
"cardNumber":"4246111111111111"). Therefore, card number is
transformed to a value of "4.24611111111E+15". The only way I can get
the function to leave this string alone is if I add in the dash
separators to the card number.

Finally, is a related issue in the deserialize function another field
value is the amount of the transaction. Again, this data is enclosed
in double quotes (ex. "amount":"10.00") and is treated as a number in
the conversion process and thus the value becomes "10". This is not a
huge problem and in my opinion is the expected behavior if the number
was not enclosed in double quotes. However, the Java library we are
using for our direct-to-host processing requires the value be a
numeric dollar amount, including the decimal point.

Any help/insight concerning these issues would be greatly appreciated.

Kind regards,
-JSLucido
-- 
Open BlueDragon Public Mailing List
 http://www.openbluedragon.org/   http://twitter.com/OpenBlueDragon
 mailing list - http://groups.google.com/group/openbd?hl=en

 !! save a network - please trim replies before posting !!

Reply via email to