JSON
-
Upload
zara-tariq -
Category
Design
-
view
104 -
download
0
description
Transcript of JSON
![Page 1: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/1.jpg)
![Page 2: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/2.jpg)
Team Members
1. Anum Hanif2. Farina Khan3. Hafiza Areeba 4. Haya Samar5. Maheen Ashraf6. Ramsha Arif7. Sadaf Allahdin8. Sobia Hashmi9. Sundus Munawar10. Zara Tariq
![Page 3: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/3.jpg)
What is JSON?
• Lightweight data-interchange format
• Subset of JavaScript
• Easy for humans to read and write
• Easy for machines to parse and generate
• Language independent
JSON
![Page 4: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/4.jpg)
Properties of JSON
• Human and machine readable format.
• Strict syntax and parsing requirements.
• Represents the most general computer science
data structures like records, lists and trees.
JSON
![Page 5: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/5.jpg)
Data Interchange
• JSON is a simple, common representation of
data.
• Communication between servers and browser
clients.
JSON
![Page 6: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/6.jpg)
Where to use JSON?• It is useful when writing any kind of JavaScript-
based application.
• I t is used primarily to transmit data between a
server and web application.
• JSON with PHP
• JSON with Perl
• JSON with Python
• JSON with JavaScript
JSON
![Page 7: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/7.jpg)
Where to use JSON?• JSON with PHP
• json_encode
• json_decode
• json_last_error
• JSON with Perl
• to_json
• from_json
• convert_blessed
JSON
![Page 8: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/8.jpg)
Where to use JSON?
JSON
• JSON with Python
• encode
• decode
• JSON with Javascript
• JSON.stringify
• JSON.parse
![Page 9: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/9.jpg)
Why JSON ?• JSON is syntax for storing and exchanging text
information.
• The JSON text format is syntactically identical
to the code for creating JavaScript objects.
• Because of this similarity, instead of using a
parser, a JS program can use the built-in
functions and execute JSON data to produce
native JavaScript objects.
JSON
![Page 10: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/10.jpg)
• 3 Reasons why you should use JSON
• Clean data
• Efficiency
• Scalability
JSON
•As compared to XML, JSON is
• smaller
• faster and
• easier to parse
Why JSON ?
![Page 11: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/11.jpg)
How to use it..?• JSON syntax is a subset of JavaScript syntax• Json Syntax Rules• Data is in name/value pairs• Data is separated by commas• Curly braces hold objects• Square brackets hold arrays
• JSON Name/Value Pairs• JSON data is written as name/value pairs• Example
• "firstName" : "John"
JSON
![Page 12: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/12.jpg)
How to use it..?• JSON values can be
A number (integer or floating point) A string (in double quotes) A Boolean (true or false) An array (in square brackets) An object (in curly brackets) null
• JSON Objects JSON objects are written inside curly brackets Objects can contain multiple name/values pairs
• Example{ "firstName":"John" , "lastName":"Doe" }
JSON
![Page 13: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/13.jpg)
How to use it..?Simple Example
JSON
![Page 14: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/14.jpg)
How to use it..?Result
JSON
![Page 15: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/15.jpg)
JSON vs. XML
JSON
JSON
• JSON is a text-based format.
• JSON data types: string, number, array, Boolean.
• JSON does not contain start and end tags.
• JSON include arrays.• JSON does not have
support for Namespaces.
XML
• XML is a Markup Language.
• XML data are all string.
• Xml contain start and end tags.
• XML doesn't include arrays.
• XML supports Namespaces.
![Page 16: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/16.jpg)
JSON vs. XML
<?xml version=“1.0” encoding=“utf-8”?>
<students> <student> <name>Ali</name> <age>20</age> <gender>male</gender> </student> <student> <name>Bilal</name> <age>21</age> <gender>male</gender> </student> </students>
“students”= [
{“name”: “Ali”, “age”: “20”,
“gender”: “Male”},
{“name”: “Bilal”, “age”: “21”,
“gender”: “Male”}
]
JSON
JSON XML
![Page 17: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/17.jpg)
JSON
Examples Of JSON
![Page 18: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/18.jpg)
Examples Of JSON• Android weather app: JSON, HTTP, Async Task and Openweathermap
HTTP Connection
OpenWeatherMap API
Async Task
JSON Object and Parser
Display DataJSON
![Page 19: JSON](https://reader036.fdocuments.in/reader036/viewer/2022081413/5479a722b4af9f892d8b45c8/html5/thumbnails/19.jpg)