As noted previously, there is a lot of overlap between the RDBMS world and the JSON world.
Identifiers
JSON is defined to allow identifiers of any kind of Unicode string, encoded in UTF-8 (or UTF-16, etc.). They begin and end with double quotation marks (U+0022), so included quotation marks and '\' must be escaped as \" or \\. Control characters (ASCII 0-x1F) must be escaped as well.
In practice, JSON identifiers conform to ECMAScript standards. There are some 68 reserved keywords (function, import, for, if, else, and so on) that should not be used as identifiers. Unexpected reserved words include abstract, await, debugger, delete, finally, instanceof, super, synchronized, transient, volatile, and yield. The spec makes a distinction between identifiers and IdentifierNames (specifically, array keys), but why risk it?
ECMAScript allows '$' and '_' anywhere in an identifier. Length or camelCasing are not part of the spec. As for length, there seems to be no limit, but as we're talking about JSON over the wire, shorter identifiers means fewer bytes transmitted.
MySQL 5.7 allows '$' and '_', too, along with 0-9, A-Z, a-z and they can do Unicode, though they're not as enthused about it as ECMAScript. Identifiers can begin with a digit, but should not consist of all digits. Identifiers cannot end with a space. Quotes for identifiers (the ` backtick) are optional. MySQL column (and table and database) names cannot be longer than 64 characters.
Identifiers
JSON is defined to allow identifiers of any kind of Unicode string, encoded in UTF-8 (or UTF-16, etc.). They begin and end with double quotation marks (U+0022), so included quotation marks and '\' must be escaped as \" or \\. Control characters (ASCII 0-x1F) must be escaped as well.
In practice, JSON identifiers conform to ECMAScript standards. There are some 68 reserved keywords (function, import, for, if, else, and so on) that should not be used as identifiers. Unexpected reserved words include abstract, await, debugger, delete, finally, instanceof, super, synchronized, transient, volatile, and yield. The spec makes a distinction between identifiers and IdentifierNames (specifically, array keys), but why risk it?
ECMAScript allows '$' and '_' anywhere in an identifier. Length or camelCasing are not part of the spec. As for length, there seems to be no limit, but as we're talking about JSON over the wire, shorter identifiers means fewer bytes transmitted.
MySQL 5.7 allows '$' and '_', too, along with 0-9, A-Z, a-z and they can do Unicode, though they're not as enthused about it as ECMAScript. Identifiers can begin with a digit, but should not consist of all digits. Identifiers cannot end with a space. Quotes for identifiers (the ` backtick) are optional. MySQL column (and table and database) names cannot be longer than 64 characters.
Comments
Post a Comment