1 Json Intro and datatype PRESENTATION.pptx

angelinjeba6 8 views 10 slides Aug 28, 2024
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

JSON


Slide Content

JSON stands for JavaScript Object Notation JSON is a text format for storing and transporting data JSON is "self-describing" and easy to understand JSON is a lightweight Data-Interchange Format. JSON Is Programming Language Independent Subset of Javascript Object literal easy to read Minimum bandwidth is needed to interchange data Supports in all browsers JSON SYNTAX { key:value }

JSON RULES Must create data within curly brackets {} { json data} Data must be written with key-value pairs { key : value } Key and value must be separated by colon : {“name” : “ram”} key should be double-quoted, if the value is a string then it must be double-quoted {“name” : “ sita ”} {“age” : 21}

When multiple data are used then it should be separated by a comma {“name” : “ram” , {“age” : 21} When array data are used then it should be represented in square brackets[] {“marks” : [12,61,99]} curly brackets are used to store/hold/represent objects JSON as a document JSON data can be created in an external file with an extension as.json

JSON Datatypes Number: Integer, Floating point number Eg: {"regno":101, "cgpa":9.1} String : Text with double quotes Eg:{"name": "John"} Boolean : true or false Eg: {"sale": true} Array: Square brackets[] Eg: { "employees":["John", "Anna", "Peter"] } Object: curly brackets, can have objects within objects. Eg: { "employee":{"name": "John", "age":30} } Null : null Eg: {“middle name": null}

Number, String, Boolean Values(Literals) data types Eg1 :{ "brand": "Crocs", "color": "pink", "size": 9, " hasLaces ": false } Eg2 : { "brand": "Crocs", "color": "pink", "size": 9, " hasLaces ": false } Arrays Eg1 :{ "fruits":[" apple","orange","mango","pineapple","grapes "] } Eg2 : { "scores":[98,23,78,89,97] }

Objects { "book1": { " title":"Life ", " author":"Luther ", "stock": 18, "price":2000 } }

Nested JSON Objects { "students": { "cse":{ "URK20CS1001" : {"name":"John","cgpa":8.7}, "URK20CS1002" : {"name":"Grace","cgpa":7.7}, "URK20CS1003" : {"name":"Lincy","cgpa":9.7} } }, "faculty":{ "cse":{ "678":{"name":"Ashok", "gender":"male","place":"Chennai"}, "857":{"name":"Arun","gender":"male","place":"Coimbatore"} } } }

Null { "person1":{ “first name":"John ", “middle name":null , “last name": “William" }, "person2":{ “first name":"David ", “ Middlename " : "W i l so n " , “last name": null }

<script> var json = { "array": [1,2,3], " boolean ": true, " color ": "gold", "status": null, "number": 123, "object": {"a": "b", "c": "d"}, "string": "Hello World" } </script>

Example: <script>         var user = new Object();         user.name="Ram";         user.age =23;         document.write ("His Name is " +user.name + " < br >And his age is " + user.age )         var user={             name:"SAM ",             age:24         }         document.write ("< br > His Name is " +user.name + " < br >And his age is " + user.age )     </script> JAVASCRIPT JSON
Tags