In order for us to help debug, you need to give us a few more details. If we don't know what's broken, we can't help you fix it :-) Remember, we know a little bit about App Engine, but nothing about your application or how it works. You'll get the best results if you include at least these two details:
1. what you expect to see when it works. 2. what you are seeing instead. Good luck! On Nov 7, 1:56 pm, Hans <[EMAIL PROTECTED]> wrote: > Thats it, I don't get a clear error. > > The Django encoder wouldn't encode my custom business objects - that's > why I thought I had to roll my own. > > Hans > > On Nov 7, 6:43 pm, Anthony <[EMAIL PROTECTED]> wrote: > > > Hard to tell without knowing what sort of errors are you getting.. > > > But, have you tried the included Django JSON encoder: > > > from django.utils import simplejson > > > object = simplejson.loads("{JSON}") > > string = simplejson.dumps(object) > > > On Nov 7, 3:22 pm, Hans <[EMAIL PROTECTED]> wrote: > > > > I have the following code to convert common objects to JSON. On my dev > > > box it works fine, but on production is simply does not and I can't > > > really debug. Any suggestions? > > > > import types > > > class TestObject(): > > > def __init__(self): > > > self.dict = {'test class':'jaja'} > > > self.name = 'testobject' > > > self.lijst = ['ss','s','jaj'] > > > self.bool = True > > > > class JsonEncoder(): > > > ATTRIBUTES_TO_SKIP = ['__doc__','__module__'] > > > > @staticmethod > > > def encode(obj): > > > return JsonEncoder._encode(obj, type(obj)) > > > > @staticmethod > > > def _encode(obj,type,baseNr = 0): > > > typeCaseSwitch= { > > > types.DictType: JsonEncoder.encodeDict > > > ,types.InstanceType: > > > JsonEncoder.encodeInstance > > > ,types.NoneType: JsonEncoder.encodeNone > > > ,types.StringType: JsonEncoder.encodeStr > > > ,types.UnicodeType: JsonEncoder.encodeStr > > > ,types.ListType: JsonEncoder.encodeList > > > ,types.BooleanType: JsonEncoder.encodeBool > > > ,types.IntType: JsonEncoder.encodeInt > > > ,types.TupleType: JsonEncoder.encodeList > > > } > > > try: > > > return typeCaseSwitch[type](obj) > > > except Exception, inst: > > > if len(obj.__class__.__bases__) > 0: > > > baseType = obj.__class__.__bases__[++baseNr] > > > return JsonEncoder._encode(obj, baseType) > > > > @staticmethod > > > def encodeDict(obj): > > > result = [] > > > for key in obj: > > > result.append(JsonEncoder.encode(key) + ':' + > > > JsonEncoder.encode(obj[key])) > > > return '{' + ','.join(result) + '}' > > > > @staticmethod > > > def encodeList(obj): > > > result = [] > > > for item in obj: > > > result.append(JsonEncoder.encode(item)) > > > return '[' + ','.join(result) + ']' if len(result) > 0 else > > > '[]' > > > > @staticmethod > > > def encodeBool(obj): > > > return str(obj).lower() > > > > @staticmethod > > > def encodeInt(obj): > > > return str(obj) > > > > @staticmethod > > > def encodeStr(obj): > > > #obj = obj.replace('/', r'\/') > > > obj = obj.replace('"', r'\"') > > > obj = obj.replace('\b', r'\b') > > > obj = obj.replace('\f', r'\f') > > > obj = obj.replace('\n', r'') > > > obj = obj.replace('\r', r'') > > > obj = obj.replace('\t', r'') > > > return '"' + str(obj).replace('\\','\\\\').replace('\"','\\ > > > \"') + '"' > > > > @staticmethod > > > def encodeNone(obj): > > > return 'null' > > > > @staticmethod > > > def encodeInstance(obj): > > > callableAttribs = [] > > > for attrib in dir(obj): > > > if not callable(getattr(obj, attrib)) and attrib not in > > > JsonEncoder.ATTRIBUTES_TO_SKIP: > > > callableAttribs.append('"' + attrib + '":' + > > > JsonEncoder.encode(getattr(obj, attrib))) > > > if len(callableAttribs) > 0: > > > return '{' + ','.join(callableAttribs) + '}' --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---