0% found this document useful (0 votes)
15 views3 pages

Understanding JSON and JavaScript Objects

JSON (JavaScript Object Notation) is a text-based format for storing and transferring data, easily convertible to JavaScript objects. It is self-describing and readable, making it suitable for communication between different programming languages. The document also explains the workings of APIs, HTTP methods, and provides a brief guide on using Postman and setting up a JSON server.

Uploaded by

Tejas Zamre
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Understanding JSON and JavaScript Objects

JSON (JavaScript Object Notation) is a text-based format for storing and transferring data, easily convertible to JavaScript objects. It is self-describing and readable, making it suitable for communication between different programming languages. The document also explains the workings of APIs, HTTP methods, and provides a brief guide on using Postman and setting up a JSON server.

Uploaded by

Tejas Zamre
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

JSON- JavaScript Object Notation

format to store and transfer data

is Like a Object

JSON is a text
Most redable format

JSON is "self-describing" and easy to understand

***********************************************************************************
*********

Why Use JSON?


The JSON format is syntactically similar to the code for creating JavaScript
objects.
Because of this, a JavaScript program can easily convert JSON data into JavaScript
objects.

Since the format is text only, JSON data can easily be sent between computers, and
used by any programming language.

***********************************************************************************
*********

2 Methods-

*****
[Link]();
********

convert JS object to JSON string- [Link]()

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

[Link]()

********************************************

[Link]()

Used to Convert JSON string data to plain JS Object

Converts a JavaScript Object Notation (JSON) string into an object.

*****************************************************************************
[Link]

*********************************************************

How does API Works

What is Web API?


API stands for Application Programming Interface.

A Web API is an application programming interface for the Web.

A Browser API can extend the functionality of a web browser.

A Server API can extend the functionality of a web server.

[Link]

[Link]
%2F&psig=AOvVaw0G9y6NOc4RcThjUDU9rMgx&ust=1698747912337000&source=images&cd=vfe&opi
=89978449&ved=0CBIQjRxqFwoTCKjopqDHnYIDFQAAAAAdAAAAABAE

************************************************
What is HTTP?
The Hypertext Transfer Protocol (HTTP) is designed to enable communications between
clients and servers.

HTTP works as a request-response protocol between a client and server.

Example: A client (browser) sends an HTTP request to the server; then the server
returns a response to the client.
The response contains status information about the request and may also contain
the requested content.

HTTP Methods
GET
POST
PUT
HEAD
DELETE
PATCH
OPTIONS
CONNECT
TRACE

*********************************************************
PUT VS PATCH method-
PUT - Update entire resources and modifying entire data

Patch- Update Partial Resource without modifying entire data

PATCH is used to apply partial updates to a resource, meaning that


only the fields that need to be changed are sent in the request body.

PUT is used to replace the entire resource with a new representation,


meaning that all the fields of the resource are sent in the request body, even if
they are not modified.

***********************************************************************

What is Postman used for?


Postman: Postman is an API(application programming interface) development tool
which helps to build, test and modify APIs. A

***********************************************************************

1. Create Directory- JSON_App

create react app- npm init


npx create-react-app my-app
cd my-app

2. setup JSON Server

cd my-app
mkdir json_data
cd json_data- > npm i -g json-server@0

3. Creating JSON file and then Start JSON server

npx json-server --watch [Link]

localhost:3000

[Link]

[Link]

Common questions

Powered by AI

JSON is preferred because it is a text format that is syntactically similar to JavaScript, making it easy to convert JSON data into JavaScript objects. This compatibility is particularly useful in web development where JavaScript is prevalent. Additionally, as a text-only format, JSON can be easily sent between computers and is usable by any programming language .

JSON might be chosen over XML for data interchange in scenarios where simplicity and ease of use are priorities. JSON's lightweight nature, ease of parsing, and integration with JavaScript-focused environments make it more suitable for modern web applications, particularly those running on platforms where JavaScript is heavily used. Additionally, JSON is more concise and readable in comparison to XML, which can be verbose .

Postman is a tool used in API development to build, test, and modify APIs. It allows developers to create HTTP requests through a user-friendly interface and view the responses returned by those requests. This is crucial for troubleshooting and ensuring that APIs function as intended during the development cycle .

Using npx with create-react-app simplifies the setup process by avoiding local installation of the create-react-app package; instead, npx runs the command directly from the npm repository. This approach, paired with a JSON server, allows for a quick setup of a development environment where developers can easily simulate and manage API calls alongside their React application, improving workflow efficiency .

JSON is considered "self-describing" because the format allows data to be written in a way that it essentially explains itself. Keys and values in JSON are clear and straightforward, which makes JSON easy to read even by those not overly familiar with it. This simplicity enhances usability across various programming languages and increases its accessibility for developers .

The PUT method is used to update entire resources, meaning all fields of the resource are sent in the request body, even if some are not modified—essentially replacing the entire resource. In contrast, the PATCH method is used for partial updates, where only the fields that need to be changed are sent in the request body. This distinction allows PATCH to be more efficient when only minor updates are necessary .

JSON.stringify() and JSON.parse() enhance JSON usability by providing seamless conversion between JavaScript objects and JSON strings. JSON.stringify() allows JavaScript values to be converted into JSON strings, making it easy to serialize data for storage or transmission. Conversely, JSON.parse() converts JSON strings back into JavaScript objects, facilitating data manipulation within the application .

The HTTP protocol works through a request-response model where a client sends an HTTP request to the server. The server processes this request and returns an HTTP response to the client. This response contains status information about the request and, if applicable, the requested content. This manner of communication is pivotal for web interactions where browser requests are made to server endpoints .

APIs act as interfaces that extend the functionality of web browsers and servers by providing a set of defined rules and endpoints through which software components can interact. Browser APIs can enhance web browsers by allowing developers to access web-based functionalities, while server APIs enable the expansion of server features by facilitating the integration of external services or applications .

JSON's text-only format supports cross-platform data interchange by ensuring that data can be easily transferred and understood across different languages and platforms without compatibility issues. As it is language-agnostic, JSON can be readily parsed and generated by most programming languages, facilitating seamless communication and data sharing in diverse and mixed-technology environments .

You might also like