I've searched around and all I know is that somehow the JSON is getting corrupted.
I am calling json.dumps on a list of dictionaries and then saving it into a django model object. When I try to read it back in by calling json.loads
I am getting the Expecting property name: line 1 column 2 (char 2)
exception thrown.
Here is my code. If there is a conversation already then it tries to load the text into the messages list and append the new one (but it doesn't succeed). If it doesn't exist then it just appends it to an empty list and saves it (which works).
convo = Conversation()
messages = []
if request.POST.get('convo_pk',''):
convo = Conversation.objects.get(pk = request.POST['convo_pk'])
messages = json.loads(convo.text) #this is where it dies
else:
convo.offer = Offer.objects.get(pk = request.POST['offer_pk'])
new_message = json.loads(request.POST['message'])
messages.append(new_message)
convo.text = messages
convo.save()
From the django admin panel this is the json that is being saved.
[{u'body': u'this is the message body', u'user_id': u'8', u'name': u'Mark', u'time': u'2013-10-10-16:32'}]