All Projects → tc39 → Proposal Well Formed Stringify

tc39 / Proposal Well Formed Stringify

Licence: mit
Proposal to prevent JSON.stringify from returning ill-formed strings

Programming Languages

ecmascript
72 projects

Labels

Projects that are alternatives of or similar to Proposal Well Formed Stringify

Unify Jdocs
A new way of working with JSON documents without using model classes or JSON schemas
Stars: ✭ 58 (-4.92%)
Mutual labels:  json
Phptdlib
PHP Extension for tdlib/td written with PHP-CPP
Stars: ✭ 59 (-3.28%)
Mutual labels:  json
Gophergameserver
🏆 Feature packed, easy-to-use game server API for Go back-ends and Javascript clients. Tutorials and examples included!
Stars: ✭ 61 (+0%)
Mutual labels:  json
Gjson
Get JSON values quickly - JSON parser for Go
Stars: ✭ 9,453 (+15396.72%)
Mutual labels:  json
Jsonschema Key Compression
Compress json-data based on its json-schema while still having valid json
Stars: ✭ 59 (-3.28%)
Mutual labels:  json
Govalid
Data validation library for golang. [MIGRATING TO NEW ADDRESS]
Stars: ✭ 59 (-3.28%)
Mutual labels:  json
Feedr
Use feedr to fetch the data from a remote url, respect its caching, and parse its data. Despite its name, it's not just for feed data but also for all data that you can feed into it (including binary data).
Stars: ✭ 56 (-8.2%)
Mutual labels:  json
Ediengine
Simple .NET EDI X12 Reader, Writer and Validator. EDI JSON Serialization and Deserialization. Written in C#
Stars: ✭ 61 (+0%)
Mutual labels:  json
Jsonfield
A reusable Django model field for storing ad-hoc JSON data
Stars: ✭ 1,101 (+1704.92%)
Mutual labels:  json
Njson
Unmarshal/Decode nested JSON by JSON Path
Stars: ✭ 61 (+0%)
Mutual labels:  json
Http Prompt
An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie
Stars: ✭ 8,329 (+13554.1%)
Mutual labels:  json
Re Txt
converts text-formats from one to another, it is very useful if you want to re-format a json file to yaml, toml to yaml, csv to yaml, ... etc
Stars: ✭ 59 (-3.28%)
Mutual labels:  json
Funcj
Assorted functional-oriented data structures and algorithms for Java.
Stars: ✭ 60 (-1.64%)
Mutual labels:  json
Rumble
⛈️ Rumble 1.11.0 "Banyan Tree"🌳 for Apache Spark | Run queries on your large-scale, messy JSON-like data (JSON, text, CSV, Parquet, ROOT, AVRO, SVM...) | No install required (just a jar to download) | Declarative Machine Learning and more
Stars: ✭ 58 (-4.92%)
Mutual labels:  json
Fhir.js
Node.JS library for serializing/deserializing FHIR resources between JS/JSON and XML using various node.js XML libraries
Stars: ✭ 61 (+0%)
Mutual labels:  json
Diver.js
Dives deep into the dom and dumps it in the object literal notation.
Stars: ✭ 57 (-6.56%)
Mutual labels:  json
Sirvy
🔗 Kirby Services API
Stars: ✭ 59 (-3.28%)
Mutual labels:  json
Whc datamodelfactory
Mac上iOS开发辅助工具,快速把json/xml数据转换生成对应模型类属性,省去麻烦手动创建,提高开发效率。Mac iOS development aid, quickly put the json/XML data transformation generates the corresponding model class attribute, save trouble created manually, improve the development efficiency.
Stars: ✭ 1,118 (+1732.79%)
Mutual labels:  json
Cssparser.js
cssparser.js is a parser that generate json from css with matched orders & structures.
Stars: ✭ 61 (+0%)
Mutual labels:  json
I18n Generator
i18n json files generator for node, web browser and command line
Stars: ✭ 60 (-1.64%)
Mutual labels:  json

Well-formed JSON.stringify

A proposal to prevent JSON.stringify from returning ill-formed Unicode strings.

Status

This proposal is at stage 4 of the TC39 Process.

Champions

  • Mathias Bynens

Motivation

RFC 8259 section 8.1 requires JSON text exchanged outside the scope of a closed ecosystem to be encoded using UTF-8, but JSON.stringify can return strings including code points that have no representation in UTF-8 (specifically, surrogate code points U+D800 through U+DFFF). And contrary to the description of JSON.stringify, such strings are not "in UTF-16" because "isolated UTF-16 code units in the range D800₁₆..DFFF₁₆ are ill-formed" per The Unicode Standard, Version 10.0.0, Section 3.4 at definition D91 and excluded from being "in UTF-16" per definition D89.

However, returning such invalid Unicode strings is unnecessary, because JSON strings can include Unicode escape sequences.

Proposed Solution

Rather than return unpaired surrogate code points as single UTF-16 code units, represent them with JSON escape sequences.

Illustrative examples

// Non-BMP characters still serialize to surrogate pairs.
JSON.stringify('𝌆')
// → '"𝌆"'
JSON.stringify('\uD834\uDF06')
// → '"𝌆"'

// Unpaired surrogate code units will serialize to escape sequences.
JSON.stringify('\uDF06\uD834')
// → '"\\udf06\\ud834"'
JSON.stringify('\uDEAD')
// → '"\\udead"'

Discussion

Backwards Compatibility

This change is backwards-compatible, under an assumption of consumer compliance with the JSON specification. User-visible effects will be limited to the replacement of some rare single UTF-16 code units in JSON.stringify output with equivalent six-character escape sequences that can be represented both in UTF-16 and in UTF-8. It is the authors' opinion that any consumer accepting the current ill-formed output will be unaffected by this change (this is true in particular of ECMAScript JSON.parse). Any consumer rejecting the current ill-formed output will have a new opportunity to accept its well-formed representation, although such consumers may still reject input that specifies strings including Unicode code points that are not scalar values (e.g., because they only accept I-JSON input), but those that accept it must have mechanisms for dealing with unpaired surrogates (as mentioned in the specification of JSON).

Validity

Unicode escape sequences are valid JSON, and—being completely ASCII—are well-formed in both UTF-16 and UTF-8.

Specification

The specification is available in ecmarkup or rendered HTML.

Implementations

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].