Formatting data for an API JSON response
up vote
0
down vote
favorite
I have a couple of questions about formating data ready for an API JSON response.
If sending a datetime value (YYYY-MM-DD HH:MM:SS format) in an API json response, if there is no datetime set, which one of these should it be:
an empty string
""
A string of
"0000-00-00 00:00:00"
null
Is it good practice to make all values have a fixed datatype (not a mixed data type) in API responses? So for example, if a value will be an array, but there are no elements in the array, should the value be made an empty array
rather than
false
ornull
so that value will always be an array?
json-api
add a comment |
up vote
0
down vote
favorite
I have a couple of questions about formating data ready for an API JSON response.
If sending a datetime value (YYYY-MM-DD HH:MM:SS format) in an API json response, if there is no datetime set, which one of these should it be:
an empty string
""
A string of
"0000-00-00 00:00:00"
null
Is it good practice to make all values have a fixed datatype (not a mixed data type) in API responses? So for example, if a value will be an array, but there are no elements in the array, should the value be made an empty array
rather than
false
ornull
so that value will always be an array?
json-api
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a couple of questions about formating data ready for an API JSON response.
If sending a datetime value (YYYY-MM-DD HH:MM:SS format) in an API json response, if there is no datetime set, which one of these should it be:
an empty string
""
A string of
"0000-00-00 00:00:00"
null
Is it good practice to make all values have a fixed datatype (not a mixed data type) in API responses? So for example, if a value will be an array, but there are no elements in the array, should the value be made an empty array
rather than
false
ornull
so that value will always be an array?
json-api
I have a couple of questions about formating data ready for an API JSON response.
If sending a datetime value (YYYY-MM-DD HH:MM:SS format) in an API json response, if there is no datetime set, which one of these should it be:
an empty string
""
A string of
"0000-00-00 00:00:00"
null
Is it good practice to make all values have a fixed datatype (not a mixed data type) in API responses? So for example, if a value will be an array, but there are no elements in the array, should the value be made an empty array
rather than
false
ornull
so that value will always be an array?
json-api
json-api
edited Nov 7 at 10:04
asked Nov 7 at 9:25
Andy
54
54
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
- you can use null data type
- You can use a nullable datatype e.g.
DateTime? MyNullableDate;
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
- you can use null data type
- You can use a nullable datatype e.g.
DateTime? MyNullableDate;
add a comment |
up vote
0
down vote
- you can use null data type
- You can use a nullable datatype e.g.
DateTime? MyNullableDate;
add a comment |
up vote
0
down vote
up vote
0
down vote
- you can use null data type
- You can use a nullable datatype e.g.
DateTime? MyNullableDate;
- you can use null data type
- You can use a nullable datatype e.g.
DateTime? MyNullableDate;
edited Nov 7 at 10:25
JJJ
29k147591
29k147591
answered Nov 7 at 9:35
Debabrata
4618
4618
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186590%2fformatting-data-for-an-api-json-response%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown