-
Recent Posts
Recent Comments
Categories
Links
Daily Archives: October 8, 2018
JSON5
JSON5 (https://spec.json5.org) https://github.com/json5/json5 nodejs讀取設定檔常使用json格式(http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf, https://tools.ietf.org/html/rfc8259), 但是json在描述時限制較多,例如在key要雙引號,字串要用雙引號不能用單引號,不能有註解等。 因此可讀性變差,JSON5主要將ECMAScript 5.1語法引入,整體看來,syntax對於熟悉javascript的使用者更友善 幾個比較大的差異 key不一定需要引號(根據ECMAScript 5.1 IdentifierName規則) Objects may have a single trailing comma. Arrays may have a single trailing comma. Strings may be single quoted/支援多行/支援 \x的escape (U+0000 through U+00FF) String更寬容的escape字元包含 JSON:All Unicode characters may … Continue reading
Posted in nodejs
Leave a comment