Skip to main content

Handling JSON Data in Angular: Fetching, Parsing, and Displaying

 A JSON object is a javascript object that is used to achieve heterogeneous communication.

Heterogenious Communication: Two different Programming Languages want to communicate with each other like Java communicates to Dotnet, and Dotnet communicates to pHP and python talks to C++ etc..

  • We require a common data format called XML or JSON which will help to achieve heterogeneous communication.
  • XML is heavy weight and requires lot of code in converting the Java to XML and XML to java but JSON is lightweight and does not require heavy code in marshalling and unmarshalling

Marshalling ==> TS/JS to JSON

Unmarshalling ==> JSON to TS/JS



  • Structure JSON is very simple not complex like XML like DTD, XSD, XPATH etc...
  • Structure of JSON is { "key1" : "value1" } { "key2" : "value2" } etc and we can have nested JSON

Sample : {

               firstName: "Vijay".

               lastName: "kumar" city: "Hyderabad",

               phone: "111111",

              email:"vijumca@gmail.com"

},

Order.json 

    Order: {

               customerName: "Sandhya", zipcode: "500037",

              orderDate: "2024-Aug-29",

              shipmentDate: "2024-Sep-2",

              products: [

                                { prodname: "iphone", qty:1},

                                { prodname:"iphonecover", qty:1}

                              ]

             payment: {

                            type: "Wallet",

                            name: GPAY,

                           number: 11111

                        }

}

Angular Framework has inbuilt capability for marshalling and unmarshalling i.e., developers no need to write code in JS to JSON and JSON to JS. When we want to submit the data to back from 

FE ==> Marshalling Displaying the JSON Data to HTML ==> Unmarshalling

Comments

© 2020 The JavaDS Hub

Designed by Open Themes & Nahuatl.mx.