*> 2nd: Talking json to a WCF / .NET client
*
> My solution here was to modify simplejson so that it also escapes the '/' 
character, and just return '/Date(...)/' as my date value. This works, and 
(based on the same reasoning used by MS) is safe for anything. But I don't 
like it; Is there any simpler solution for that, that would escape 
*only*datetime values?

In case anyone is having the same problem, the following (inserted in my 
database model file) does this without having to modify the simplejson files 
directly:

#PATCH simplejson to output data in the weird microsoft style
from gluon.contrib.simplejson import encoder
import re
encoder.ESCAPE = re.compile(r'[\x00-\x1f\\/"\b\f\n\r\t]')
encoder.ESCAPE_ASCII = re.compile(r'([\\/"]|[^\ -~])')
encoder.ESCAPE_DCT['/'] = r'\/'
del encoder
del re

Note that this escapes *every* use of slash (/), so it might not be what you 
want - but for now, it's good enough for me.

Reply via email to