why we use package json code example

Example 1: package.json what is it for

Metadata that is specific to the project.  It contains a collection of any 
given project's dependencies.

A web application is used to identify the project and acts as a 
baseline for users and contributors to get information about the project.

Example 2: what is package.json

metadata specific to the project
a web application, Node.js module, or even just a plain JavaScirpt library. 
identifies the project and acts as a baseline for users and contributors 
to get information about the project.
contains a collection of any given project's dependencies