JSON web service: Whats the best way to output currency?
As a string OR
"Amount": "100.12345"
As an Number?
"Amount": 100.12345
PayЗal and Google Checkout output json as a string. Why?
JSON web service: Whats the best way to output currency?
As a string OR
"Amount": "100.12345"
As an Number?
"Amount": 100.12345
PayЗal and Google Checkout output json as a string. Why?
I would do an integer of cents to keep it as simple as possible.
"Amount": 1045
...
var amount = json.amount/100;
...
amount === 10.45
In my opinion use number until parsing in C# will be to decimal (not double). For more information you can look here Why not use Double or Float to represent currency?
If you are using JSON.NET see this thread Json.NET Primitive Types - use Decimal instead of Double
In JavaScript it doesn't matter what you use.