Proper JSON Serialization of Long/BigInt/Int64 #8
-
From @nickclarity Regarding serialization and types in JSON, how should we represent a Long/Big Int/64 Bit Int? The SIP specifically refers to Number as 32 bit, would that imply Longs should be represented as Strings? https://atlassian.spscommerce.com/wiki/display/SIP/API+-+Serialization#APISerialization-Number I know as far as JSON is concerned it doesn't matter, it's just a serialization format. But what if the client of the service is JavaScript? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Great callout @nickclarity. I believe your interpretation to be closest to the original design of the standards. Basically, 64-bit integers are a problem for compatibility in some API consumers, mainly we are talking JavaScript as you suggest (I'm not sure I can think of another). BUT that is a pretty big concern for some APIs. So some of this depends on knowing the consumer of your API to make the best decision. However, building an API platform moving forward, it is fair to expect that you have to build for the lowest common parser, and I have updated the API standards to indicate that with some more specific details that apply here. A quick overview:
Updates: https://atlassian.spscommerce.com/wiki/display/SIP/API+-+Serialization#APISerialization-Number |
Beta Was this translation helpful? Give feedback.
-
We have |
Beta Was this translation helpful? Give feedback.
Great callout @nickclarity. I believe your interpretation to be closest to the original design of the standards.
Basically, 64-bit integers are a problem for compatibility in some API consumers, mainly we are talking JavaScript as you suggest (I'm not sure I can think of another). BUT that is a pretty big concern for some APIs. So some of this depends on knowing the consumer of your API to make the best decision. However, building an API platform moving forward, it is fair to expect that you have to build for the lowest common parser, and I have updated the API standards to indicate that with some more specific details that apply here.
A quick overview: