Matching properties with reserved names #17

Closed
chrismytton opened this Issue Jun 2, 2011 · 4 comments

Comments

Projects
None yet
2 participants

I am testing JSONSelect against some activity streams json. The activity streams specification defines an object property in the json.

When I try to match the selector .object .objectType I am getting string required after ..

It seems that object is a reserved word for type selectors. I'm hoping a change to this regular expression will solve the problem, but I'm not sure what?

Owner

lloyd commented Jun 2, 2011

You may use quotes around property names to both force them to be interpreted as strings and to include chars like spaces and control chars that are allowable by the json spec:

."object" .objectType

Going to leave this open though, it seems like the js parser could disambiguate given context.

Awesome! Thanks for the quick response.

Also worth noting that it seems that the same error occurs when the reserved name is used as part of the property name, so your example would have to be written as:

."object" ."objectType"

Actually I'm getting invalid json string when using the above selector? Not sure if that is related to the previous issue though?

This selector also gives the same error:

."name" ."first"
Owner

lloyd commented Jun 2, 2011

oh, that's no good. I'll add a test or two and check it out...

@lloyd lloyd closed this in e3ce679 Jun 2, 2011

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