Skip to content

2. Escape convention

Plain objects in user data may contain keys starting with $. To keep them distinguishable from typed values, ECSON escapes every such key, regardless of which tags are registered.

ESCAPE_SERIALIZE MUST

When serializing a plain object, every key starting with $ MUST be prefixed with an additional $.

ESCAPE_DESERIALIZE MUST

When deserializing a plain object, every key starting with $$ MUST have one leading $ removed.

ESCAPE_NOT_TYPED MUST

An object whose single key starts with $$ MUST be treated as an escaped plain object, never as a typed value.

DUPLICATE_KEYS MUST

When a JSON object has the same key more than once, the last one MUST be used, as ECMAScript JSON.parse does. This happens before TYPED_VALUE and TYPED_PLAIN_OTHERWISE count the keys, so { "$date": 0, "$date": 1 } is a typed value with the form 1.

ESCAPE_COLLISION MUST

When two keys of a plain object become equal after removing the escape (such as $$a and $a), deserialization MUST fail.

PROTO_OWN_PROPERTY MUST

In hosts where the key __proto__ sets the prototype of an object, such as ECMAScript, a deserialized key __proto__ MUST become an own property, never the prototype.

Source: lingodata/ecson@fe27835 · spec/sections/02-escape.md · ecson 0.2.0 (draft)

LingoData specifications, reference implementations and this site are licensed under the Apache License 2.0. Copyright 2026 Gustavo Gondim.