Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
JSON schema
is a JSON document that describes other JSON document. It is a specification for JSON based format to define the structure of JSON data
- Describes your existing data format
- Defines the structure of a JSON message
- Clear, human- and machine-readable documentation
- Complete structural validation, useful for automated testing
- Complete structural validation, validating JSON message
- Can be used to validate API request and response
by Valeri Tandilashvili
4 years ago
0
JSON
JSON schema
JSON Tutorial
1
by Valeri Tandilashvili
4 years ago
0
JSON
JSON Beginner Tutorial
1
by Valeri Tandilashvili
4 years ago
0
JSON
JSON Beginner Tutorial
1
JSON is built on 2 structures:
Object
- a collection of key/value pairs
Array
- an ordered list of values
by Valeri Tandilashvili
4 years ago
0
JSON
JSON Beginner Tutorial
1
Creates JSON string from a JavaScript object
var obj = { name: "John", age: 30, city: "New York" };

// Converts object into JSON string
var myJSON = JSON.stringify(obj);

// Puts the string into element with id: demo
document.getElementById("demo").innerHTML = myJSON;
by Valeri Tandilashvili
4 years ago
0
JSON
JavaScript
JS JSON
1
JSON.parse()
Parses the data and converts it into a JavaScript object
let txt = '{"name":"John", "age":30, "city":"New York"}'

// Converts JSON string into a JavaScript object.
let obj = JSON.parse(txt);

// Puts the data into "p" element with id: demo
document.getElementById("demo").innerHTML = obj.name + ", " + obj.age;
by Valeri Tandilashvili
4 years ago
0
JSON
JavaScript
JS JSON
1
The following example shows how to convert an array into JSON
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);

// Returns the JSON representation of a value (pretty printed)
echo json_encode($arr, JSON_PRETTY_PRINT);
Result of the above code
{
    "a": 1,
    "b": 2,
    "c": 3,
    "d": 4,
    "e": 5
}
The following example shows how the PHP objects can be converted into JSON
class Emp {
    public $name = "";
    public $hobbies  = [];
    public $birthdate = "";
}

$e = new Emp();
$e->name = "sachin";
$e->hobbies  = ["sport", "reading"];
$e->birthdate = date('Y-m-d', strtotime('2015-11-18'));

echo json_encode($e);
The above code will produce the following result
{"name":"sachin","hobbies":["sport","reading"],"birthdate":"2015-11-18"}
Decoding JSON in PHP (json_decode) The following example shows how PHP can be used to decode JSON objects
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';

// Decoding into an object
var_dump(json_decode($json));

// Decoding into an array
var_dump(json_decode($json, true));
While executing, it will produce the following result
object(stdClass)#1 (5) {
  ["a"]=> int(1)
  ["b"]=> int(2)
  ["c"]=> int(3)
  ["d"]=> int(4)
  ["e"]=> int(5)
}
array(5) {
  ["a"]=> int(1)
  ["b"]=> int(2)
  ["c"]=> int(3)
  ["d"]=> int(4)
  ["e"]=> int(5)
}
by Valeri Tandilashvili
4 years ago
0
JSON
JSON Tutorial
1
JSON is Like XML Because
- Both JSON and XML are "self describing" (human readable)
- Both JSON and XML are hierarchical (values within values)
- Both JSON and XML are language independent
- Both JSON and XML can be parsed and used by lots of programming languages
- Both JSON and XML can be fetched with an XMLHttpRequest
JSON is Unlike XML Because
+ JSON doesn't use end tag
+ JSON is shorter
+ JSON is quicker to read and write
+ JSON can use arrays
+ Better Performance
+ JSON can be parsed easily
+ JSON object has a type
+ All major JavaScript frameworks support JSON
+ Supported by all major JavaScript frameworks
+ Supported by most backend technologies
+ JSON is recognized natively by JavaScript (as object)
- JSON doesn't support comments
- JSON can not use attributes
- JSON offers poor extensibility as no namespace support
- Supports limited data types
JSON and XML examples JSON (size: 52 bytes)
{
   "company": Volkswagen,
   "name": "Vento",
   "price": 800000
}
XML (size: 79 bytes)
<car>
   <company>Volkswagen</company>
   <name>Vento</name>
   <price>800000</price>
</car>
Another example JSON
{
   "employees":[
      {"firstName":"John", "lastName":"Doe"},
      {"firstName":"Anna", "lastName":"Smith"},
      {"firstName":"Peter", "lastName":"Jones"}
   ]
}
XML
<employees>
  <employee>
    <firstName>John</firstName> <lastName>Doe</lastName>
  </employee>
  <employee>
    <firstName>Anna</firstName> <lastName>Smith</lastName>
  </employee>
  <employee>
    <firstName>Peter</firstName> <lastName>Jones</lastName>
  </employee>
</employees>
by Valeri Tandilashvili
4 years ago
0
JSON
JSON Tutorial
1
- a function
- a date
- a symbol
- undefined
by Valeri Tandilashvili
4 years ago
0
JSON
JS JSON
1
It is an unordered set of
key/value
pairs Each key is followed by colon
:
key/value
pairs are separated by
comma
The keys must be strings and should be different from each other Objects should be used when the
key
names are arbitrary
strings
Objects are enclosed in curly braces
{}
, it starts with
{
and ends with
}
{
   "id": "011A",
   "language": "JAVA",
   "price": 500,
}
by Valeri Tandilashvili
4 years ago
0
JSON
JSON Tutorial
1
Results: 1578