Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CanJS tries to parse JSON-map which contains a dot in the key #296

Closed
ghost opened this issue Mar 4, 2013 · 2 comments
Closed

CanJS tries to parse JSON-map which contains a dot in the key #296

ghost opened this issue Mar 4, 2013 · 2 comments
Milestone

Comments

@ghost
Copy link

ghost commented Mar 4, 2013

My rest service return a map of key-value pairs. The key may contain dots. If I try to access this with can.Model an exception is thrown:

Uncaught can.Observe: Object does not exist can.jquery.js:695
can.Observe.can.Construct._set can.jquery.js:695
can.Observe.can.Construct._attrs can.jquery.js:792
can.Observe.can.Construct.attr can.jquery.js:607
can.Observe.can.Construct.setup can.jquery.js:588
can.extend.newInstance can.jquery.js:270
Constructor can.jquery.js:350
hookupBubble can.jquery.js:446
can.Observe.can.Construct.__set can.jquery.js:715
can.Observe.can.Construct._set can.jquery.js:693
can.Observe.can.Construct.attr can.jquery.js:614
can.Model.can.Observe.models can.jquery.js:1317
can.each can.jquery.js:45
can.Model.can.Observe.models can.jquery.js:1315
d.abort can.jquery.js:1054
jQuery.extend.Deferred.promise.then.jQuery.Deferred.fns jquery.js:1059
jQuery.Callbacks.fire jquery.js:910
jQuery.Callbacks.self.fireWith jquery.js:1020
done jquery.js:7234
jQuery.ajaxTransport.send.callback jquery.js:7926

If I remove the dots it works. Here's an example of the JSON message which leads to the error:

{"key.1":"value1","key.2":"value2 "}

Any idea if this is a CanJS bug or how I could solve this problem?

@daffl
Copy link
Contributor

daffl commented Mar 4, 2013

This is the same as issue #257. Maybe the workaround mentioned there works for you, too? A fix for this should definitely be part of 1.2

@ghost
Copy link
Author

ghost commented Mar 5, 2013

Yes, I have noticed afterwards that issue #257 is probably related. The workaround also worked for me, and then I can access the attributes using result.__get('key.1').
A fix for this would be great.
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant