{"id":256,"date":"2018-04-30T17:17:41","date_gmt":"2018-04-30T17:17:41","guid":{"rendered":"https:\/\/restfulapi.net\/?p=256"},"modified":"2021-09-27T23:10:39","modified_gmt":"2021-09-27T17:40:39","slug":"json-data-types","status":"publish","type":"post","link":"https:\/\/restfulapi.net\/json-data-types\/","title":{"rendered":"JSON Data Types"},"content":{"rendered":"\n
At the granular level, JSON consists of 6 data types. <\/p>\n\n\n\n
The first four data types (string, number, boolean and null) can be referred to as simple data types<\/strong>. The other two data types (object and array) can be referred to as complex data types<\/strong>.<\/p>\n\n\n\n Let’s learn about each data type one by one.<\/p>\n\n\n\n A string is a sequence of zero or more Unicode characters, enclosed between JSON Strings can contain the following backslash-escaped characters:<\/p>\n\n\n\n JSON numbers follow JavaScript\u2019s double-precision floating-point format.<\/p>\n\n\n\n Booleans values can be either Although technically not a value Type, At the granular level, JSON consists of 6 data types. The first four data types (string, number, boolean and null) can be referred to as simple data types. The other two data types (object and array) can be referred to as complex data types. string number boolean null\/empty object array Let’s learn about each data … Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":249,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[17],"_links":{"self":[{"href":"https:\/\/restfulapi.net\/wp-json\/wp\/v2\/posts\/256"}],"collection":[{"href":"https:\/\/restfulapi.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/restfulapi.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/restfulapi.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/restfulapi.net\/wp-json\/wp\/v2\/comments?post=256"}],"version-history":[{"count":0,"href":"https:\/\/restfulapi.net\/wp-json\/wp\/v2\/posts\/256\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/restfulapi.net\/wp-json\/wp\/v2\/media\/249"}],"wp:attachment":[{"href":"https:\/\/restfulapi.net\/wp-json\/wp\/v2\/media?parent=256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/restfulapi.net\/wp-json\/wp\/v2\/categories?post=256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/restfulapi.net\/wp-json\/wp\/v2\/tags?post=256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}1. String<\/h3>\n\n\n\n
\"<\/code> and
\"<\/code> (double quotes). Strings wrapped in single quotes
'<\/code> are not valid.<\/p>\n\n\n\n
{\r\n \"color\" : \"Purple\"\r\n}<\/code><\/pre>\n\n\n\n
\\\"<\/code> – Double quote<\/li>
\\\\<\/code> – Backslash<\/li>
\\\/<\/code> – Forward slash<\/li>
\\b<\/code> – Backspace<\/li>
\\f<\/code> – Form feed<\/li>
\\n<\/code> – Newline<\/li>
\\r<\/code> – Carriage return<\/li>
\\t<\/code> – Tab<\/li>
\\u<\/code> – Trailed by four hex digits<\/li><\/ul>\n\n\n\n
2. Number<\/h3>\n\n\n\n
base 10<\/code> with no superfluous leading zeros (e.g. 67, 1, 100).<\/li>
-10<\/code>.<\/li>
.5<\/code>).<\/li>
e<\/code> or
E<\/code> with a plus or minus sign to indicate positive or negative exponentiation.<\/li>
{\r\n\t\"number_1\" : 210,\r\n\t\"number_2\" : -210,\r\n\t\"number_3\" : 21.05,\r\n\t\"number_4\" : 1.0E+2\r\n}\r\n<\/code><\/pre>\n\n\n\n
3. Boolean<\/h3>\n\n\n\n
true<\/code> or
false<\/code>. Boolean values are not surrounded by quotes and will be treated as string values.<\/p>\n\n\n\n
{\r\n\t\"visibility\" : true\r\n}<\/code><\/pre>\n\n\n\n
4. null<\/h3>\n\n\n\n
null<\/code> is a special value in JSON. When there is no value to assign to a key, it can be treated as
null<\/code>.<\/p>\n\n\n\n
null<\/code> value should not be surrounded by quotes.<\/p>\n\n\n\n
{\r\n\t\"visibility\" : true,\r\n\t\"popularity\" : null, \/\/empty\r\n\t\"id\" : 210\r\n}<\/code><\/pre>\n\n\n\n
5. Object<\/h3>\n\n\n\n
{\r\n\t\"visibility\" : true,\r\n\t\"popularity\" : \"immense\",\r\n\t\"id\" : 210\r\n}<\/code><\/pre>\n\n\n\n
6. Array<\/h3>\n\n\n\n
[<\/code> (left bracket) and ends with
]<\/code> (right bracket).<\/li>
,<\/code> (comma).<\/li><\/ol>\n\n\n\n
{\r\n\t\"ids\" : [\"1\",\"2\",\"3\"]\r\n}\r\n\r\n\/\/or\r\n\r\n{\r\n\"ids\" : [\r\n\t\t{\"id\" : 1},\r\n\t\t{\"id\" : 2},\r\n\t\t{\"id\" : 3}\r\n\t]\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"