19

JSON

Embed Size (px)

DESCRIPTION

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.

Citation preview

Page 1: JSON
Page 2: JSON

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

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

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

Data Interchange

• JSON is a simple, common representation of

data.

• Communication between servers and browser

clients.

JSON

Page 6: JSON

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

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

Where to use JSON?

JSON

• JSON with Python

• encode

• decode

• JSON with Javascript

• JSON.stringify

• JSON.parse

Page 9: JSON

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

• 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

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

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

How to use it..?Simple Example

JSON

Page 14: JSON

How to use it..?Result

JSON

Page 15: JSON

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

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

JSON

Examples Of JSON

Page 18: JSON

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