Please put the change of attrkey and charkey in the readme #58

kmpm opened this Issue Oct 1, 2012 · 1 comment


None yet
2 participants

kmpm commented Oct 1, 2012

I don't know the rationale behind changing the attrkey from "@" to "$" in version 0.2 but
mongodb throws an error if I try to save the document as it is.
[Error: key $ must not start with '$']

I found out that it could be overridden by


But it would be nice, not having to read the source could to figure it out.

@Leonidas-from-XIV Leonidas-from-XIV added a commit that referenced this issue Oct 1, 2012

@Leonidas-from-XIV Leonidas-from-XIV Documented charkey and attrkey options.
Changed defaults in version 0.2, fixes issue #58.

Leonidas-from-XIV commented Oct 1, 2012

It can be easier/better specified with Parser({attrkey: '@'}) which does not overwrite the default values for all new parser instances and does not depend that you use version 0.2.x. But you are right, I forgot to add the documentation in the README file, just added that in the commit and will be part of the next release.

The rationale behind changing it is that using "@" and "#" as keys requires them to be quoted in literal syntax, i.e. foo["@"].bar, whereas foo.$.bar is a valid literal key name in JavaScript. Same goes for the change from "#" to "_".

I released version 0.2 to specifically change the defaults to do something more sensible out-of-the-box. It might create some problems, therefore I've left in the default settings of version 0.1, to make migration easy. With the 0.1-mode it should have identical output as version 0.1.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment