Multipage preference

Stage 0 Draft / October 1, 2026

Frozen JSON modules

This proposal builds on top of the JSON.parse Options proposal, which introduces JSON Parse Options Records and adds an options parameter to ParseJSON.

13 ECMAScript Language: Expressions

13.3 Left-Hand-Side Expressions

13.3.10 Import Calls

13.3.10.2 EvaluateImportCall ( specifierExpr [ , optionsExpr ] )

The abstract operation EvaluateImportCall takes argument specifierExpr (a Parse Node) and optional argument optionsExpr (a Parse Node) and returns either a normal completion containing a Promise or an abrupt completion. It performs the following steps when called:

  1. Let referrer be GetActiveScriptOrModule().
  2. If referrer is null, set referrer to the current Realm Record.
  3. Let specifierRef be ? Evaluation of specifierExpr.
  4. Let specifier be ? GetValue(specifierRef).
  5. If optionsExpr is present, then
    1. Let optionsRef be ? Evaluation of optionsExpr.
    2. Let options be ? GetValue(optionsRef).
  6. Else,
    1. Let options be undefined.
  7. Let promiseCapability be ! NewPromiseCapability(%Promise%).
  8. Let specifierString be Completion(ToString(specifier)).
  9. IfAbruptRejectPromise(specifierString, promiseCapability).
  10. Let attrs be a new empty List.
  11. If options is not undefined, then
    1. If options is not an Object, then
      1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
      2. Return promiseCapability.[[Promise]].
    2. Let attrsObj be Completion(Get(options, "with")).
    3. IfAbruptRejectPromise(attrsObj, promiseCapability).
    4. If attrsObj is not undefined, then
      1. If attrsObj is not an Object, then
        1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
        2. Return promiseCapability.[[Promise]].
      2. Let entries be Completion(EnumerableOwnProperties(attrsObj, key+value)).
      3. IfAbruptRejectPromise(entries, promiseCapability).
      4. For each element entry of entries, do
        1. Let key be ! Get(entry, "0").
        2. Let value be ! Get(entry, "1").
        3. If key is a String, then
          1. If value is not a Stringneither a String nor a Boolean, then
            1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
            2. Return promiseCapability.[[Promise]].
          2. Append the ImportAttribute Record { [[Key]]: key, [[Value]]: value } to attrs.
    5. If AllImportAttributesSupported(attrs) is false, then
      1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
      2. Return promiseCapability.[[Promise]].
    6. Sort attrs according to the lexicographic order of their [[Key]] field, treating the value of each such field as a sequence of UTF-16 code unit values. NOTE: This sorting is observable only in that hosts are prohibited from changing behaviour based on the order in which attributes are enumerated.
  12. Let moduleRequest be a new ModuleRequest Record { [[Specifier]]: specifierString, [[Attributes]]: attrs }.
  13. Perform HostLoadImportedModule(referrer, moduleRequest, empty, promiseCapability).
  14. Return promiseCapability.[[Promise]].

16 ECMAScript Language: Scripts and Modules

16.2 Modules

16.2.1 Module Semantics

16.2.1.3 ModuleRequest Records

An ImportAttribute Record consists of the following fields:

Table 1: ImportAttribute Record Fields
Field Name Value Type Meaning
[[Key]] a String The attribute key
[[Value]] a String or a Boolean The attribute value

16.2.1.8 Synthetic Module Records

16.2.1.8.2 ParseJSONModule ( source, attributes )

The abstract operation ParseJSONModule takes arguments source (a String) and attributes (a List of ImportAttribute Records) and returns either a normal completion containing a Synthetic Module Record, or a throw completion. It performs the following steps when called:

  1. Let options be ? CreateJSONParseOptionsFromImportAttributes(attributes).
  2. Let parseResult be ? ParseJSON(source, options).
  3. Return CreateDefaultExportSyntheticModule(parseResult.[[Value]]).

16.2.1.8.3 CreateJSONParseOptionsFromImportAttributes ( attributes )

The abstract operation CreateJSONParseOptionsFromImportAttributes takes argument attributes (a List of ImportAttribute Records) and returns either a normal completion containing a JSON Parse Options Record or a throw completion. It performs the following steps when called:

  1. Let freeze be false.
  2. For each ImportAttribute Record attr of attributes, do
    1. If attr.[[Key]] is "freeze", then
      1. If attr.[[Value]] is not a Boolean, throw a TypeError exception.
      2. Set freeze to attr.[[Value]].
  3. Return the JSON Parse Options Record { [[Freeze]]: freeze, [[PreferNullPrototype]]: freeze }.

16.2.1.10 HostLoadImportedModule ( referrer, moduleRequest, hostDefined, payload )

The host-defined abstract operation HostLoadImportedModule takes arguments referrer (a Script Record, a Cyclic Module Record, or a Realm Record), moduleRequest (a ModuleRequest Record), hostDefined (anything), and payload (a GraphLoadingState Record or a PromiseCapability Record) and returns unused.

An implementation of HostLoadImportedModule must conform to the following requirements:

16.2.2 Imports

Syntax

WithEntries : AttributeKey : StringLiteral AttributeValue AttributeKey : StringLiteral AttributeValue , WithEntries AttributeValue : StringLiteral BooleanLiteral

16.2.2.4 Static Semantics: WithClauseToAttributes

The syntax-directed operation WithClauseToAttributes takes no arguments and returns a List of ImportAttribute Records. It is defined piecewise over the following productions:

WithEntries : AttributeKey : StringLiteral AttributeValue
  1. Let key be the PropName of AttributeKey.
  2. Let entry be the ImportAttribute Record { [[Key]]: key, [[Value]]: the SV of StringLiteralthe ImportAttributeValue of AttributeValue }.
  3. Return « entry ».
WithEntries : AttributeKey : StringLiteral AttributeValue , WithEntries
  1. Let key be the PropName of AttributeKey.
  2. Let entry be the ImportAttribute Record { [[Key]]: key, [[Value]]: the SV of StringLiteralthe ImportAttributeValue of AttributeValue }.
  3. Let rest be WithClauseToAttributes of WithEntries.
  4. Return the list-concatenation of « entry » and rest.

16.2.2.5 Static Semantics: ImportAttributeValue

The syntax-directed operation ImportAttributeValue takes no arguments and returns a String or a Boolean. It is defined piecewise over the following productions:

AttributeValue : StringLiteral
  1. Return the SV of StringLiteral.
AttributeValue : BooleanLiteral
  1. If BooleanLiteral is the token false, return false.
  2. If BooleanLiteral is the token true, return true.

25 Structured Data

25.5 The JSON Object

25.5.2 JSON.parse ( text [ , reviverOrOptions ] )

25.5.2.1 ParseJSON ( text, options )

The abstract operation ParseJSON takes arguments text (a String) and options (a JSON Parse Options Record) and returns either a normal completion containing a JSON Parse Record, or a throw completion.

Editor's Note

This signature is defined by the JSON.parse Options proposal and is only repeated here for reference. This proposal does not change ParseJSON.

Copyright & Software License

Software License

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.