JSON Stringify Polyfill
The Stringify function is inside the page.tsx
const Data = {
name: "Arjunan",
age: 12,
job: "Developer",
single: true,
arrayCheck: [12, true, 100, "John Cena", "Undertaker", { place: "London" }],
company: {
name: "XYZ Limited",
place: "Bengaluru",
valuation: 1000,
funded: true,
employees: [1, 2, 3, 4],
food: {
breakFast: "bread",
Lunch: [{ drinks: true, softDrink: "Lemon" }, "Chicken"],
dinner: "Chappati",
},
},
};
JSON.stringify(Data)
'{"name":"Arjunan","age":12,"job":"Developer","single":true,"arrayCheck":[12,true,100,"
John Cena","Undertaker",{"place":"London"}],"company":{"name":"XYZ Limited","place":"Bengaluru","
valuation":1000,"funded":true,"employees":[1,2,3,4],"food":{"breakFast":"bread","
Lunch":[{"drinks":true,"softDrink":"Lemon"},"Chicken"],"dinner":"Chappati"}}}'
console.log(Stringify(Data));
{"name":"Arjunan","age":12,"job":"Developer","single":true,"arrayCheck":[12,true,100,"
John Cena","Undertaker",{"place":"London"}],"company":{"name":"XYZ Limited","place":"Bengaluru","
valuation":1000,"funded":true,"employees":[1,2,3,4],"food":{"breakFast":"bread","
Lunch":[{"drinks":true,"softDrink":"Lemon"},"Chicken"],"dinner":"Chappati"}}}
After calling Stringify(Data) function.
{"name":"Arjunan","age":12,"job":"Developer","single":true,"arrayCheck":[12,true,100,"John Cena","Undertaker",{"place":"London"}],"company":{"name":"XYZ Limited","place":"Bengaluru","valuation":1000,"funded":true,"employees":[1,2,3,4],"food":{"breakFast":"bread","Lunch":[{"drinks":true,"softDrink":"Lemon"},"Chicken"],"dinner":"Chappati"}}}