Get the App
SLTechnology News&Howtos  ›  Development  › 

How to parse the application of json.stringify () and json.parse ()

Shulou Source: shulou.com Published: 2022-06-02 06:49:51 10月01日 Update

This article will explain in detail how to analyze the application of json.stringify () and json.parse (). The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.

JSON.stringify () converts the js object to a JSON string, while JSON.parse () converts the JSON string into an object js object.

Application:

/ / determine whether the array contains an object function checkObjInArray (arr,obj) {/ / if (! arr) {/ / arr = [{name:'aaa'}, {name:'bbb'}, {name:'ccc'},]; / /} / / if (! obj) {/ / obj = {name:'ddd'} / /} if (JSON.stringify (arr) .indexOf (JSON.stringify (obj))! =-1) {return true;} else {return false;}} / / determine whether two arrays / objects are equal (obj1,obj2) {if (JSON.stringify (obj1) = JSON.stringify (obj2)) {return true;} else {return false }} this is the end of the application on how to parse json.stringify () and json.parse (). I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Objects applications content characters strings arrays articles more knowledge articles good quality reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Microsoft Linux Redmi Shulou Technology