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

Already on GitHub? Sign in to your account

Allow for overriding JS json deserializing function #1564

Closed
stevozilik opened this Issue Feb 21, 2013 · 2 comments

Comments

Projects
None yet
3 participants

Currently signalr.js is hardcoded to use window.JSON.parse function for deserializing messages. The problem is that function is not capable of deserializing javascript dates i.e:

..."ServerTime":new Date(1361310055896)...

the $.connection object could expose a function that would be used for deserializing and by default use the window.JSON.parse, but allowing for overriding to any other deserializing func.

I guess same goes for serialization process, to be consistent.

@ghost ghost assigned DamianEdwards May 1, 2013

@DamianEdwards DamianEdwards added a commit that referenced this issue May 7, 2013

@DamianEdwards DamianEdwards Support custom json object in JS client
- Added connection.prototype.json which is initialized as window.JSON
- Changed default ajax content type to text
- Added connection._parseRespons helper to parse ajax responses from text to JSON (when it's not JSONP)
- Update all JS client code to use connection._parseResponse
- Added unit & functional tests
- Updated affected tests
- #1564
1ce3d1f

@DamianEdwards DamianEdwards added a commit that referenced this issue May 7, 2013

@DamianEdwards DamianEdwards Support custom json object in JS client
- Added connection.prototype.json which is initialized as window.JSON
- Changed default ajax content type to text
- Added connection._parseRespons helper to parse ajax responses from text to JSON (when it's not JSONP)
- Update all JS client code to use connection._parseResponse
- Added unit & functional tests
- Updated affected tests
- #1564
17d9040

@ghost ghost assigned Xiaohongt May 7, 2013

Owner

DamianEdwards commented May 7, 2013

The JS client connection object now has a "json" property you can set to a custom object with parse and stringify methods. It defaults to window.JSON.

Contributor

Xiaohongt commented May 16, 2013

verified

@Xiaohongt Xiaohongt closed this May 16, 2013

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