共用方式為


JSON Object (Windows Scripting - JScript)

 

An intrinsic object that provides methods to convert JScript values to and from the JavaScript Object Notation (JSON) format. The JSON.stringify method serializes a JScript value to JSON text. The JSON.parse method deserializes JSON text to produce a JScript value.

Syntax

JSON.[method]

Arguments

  • Method
    Required. Name of one of the methods of the JSON object.

Remarks

You cannot create a JSON object by using the new operator. An error occurs if you try to do this. However, you can override or modify the JSON object.

The scripting engine creates the JSON object when the engine is loaded. All of its methods and properties are available to your script at all times.

To use the intrinsic JSON object, make sure that you do not override it with another JSON object that is defined in your script. You may need to modify existing script statements that detect the presence of a JSON object because those statements will evaluate differently. This is demonstrated in the following example.

if (!this.JSON) {
    // JSON object does not exist.
    }

In the previous example, !this.JSON evaluates to false in JScript Version 5.8 and above. Therefore, the code inside the if statement does not execute.

Methods

JSON.parse Method (Windows Scripting - JScript)

JSON.stringify Method (Windows Scripting - JScript)

Requirements

Version 5.8

Note

Starting with JScript 5.8, by default, the JScript scripting engine supports the language feature set as it existed in version 5.7. This is to maintain compatibility with the earlier versions of the engine. To use the complete language feature set of version 5.8, the Windows Script interface host has to invoke IActiveScriptProperty::SetProperty.

Internet Explorer 8 opts into the JScript 5.8 language features when the document mode for Internet Explorer 8 is "Internet Explorer 8 Standards" mode. For other document modes, Internet Explorer uses the version 5.7 feature set.

JScript 5.8 includes native JavaScript Object Notation (JSON) support and the accessor methods for Document Object Model (DOM) prototypes.

Change History

Date

History

Reason

August 2008

Added topic.

Information enhancement.

See Also

toJSON Method
JScript Objects