What exactly is the class name of "JSON object"?

if JSON is just a data format, what exactly is the class name of the "JSON object"?
      let i = {
        "hello": 123
      }
      
      console.info(i.constructor.name) // Object
      
      i = new Date();
      console.info(i.constructor.name) // Date

suddenly struggled with this problem. Does the name of the output of the
JSON object ( Object ) mean that the name of the object in JSON format is the object?

Mar.09,2021

there is no JSON class that can be instantiated. Whether you can use JSON.stringify () or JSON.parse () , they are all JSON tool classes in the javascript standard library, and the ontology of JSON is actually a text string based on javascript syntax, but the JSON tool classes in all languages have the ability to parse this text string into data structures that match the language. Because the core of JSON is only responsible for "exchange" and "data", the exchanged data is neutral, so there is no point in instantiating it alone (its data is directly used by other programs, encapsulation wastes memory and reduces efficiency).


your I is just a simple Object .
JSON is a language-independent text format.
JSON.stringify ({a: 1}) this serialization is used to convert Object to JSON .
JSON.parse ('{"a": 1}') is the operation that deserializes JSON .

Menu