Initialize from JSON string

Issue #7 closed
Angel Rodriguez created an issue

Hello,

I've been test driving your project and it has worked well but i came across a situation that I'm hacking out right now in order to get this to work.

Here's the deal, I'm polling data from a RabbitMQ instance and the data pushed there is already in JSON format. We have a poller data goes and gets the messages from the queue and pushes these messages (JSON strings) to a table in our DB where we later on poll (using a regular Django QuerySet), parse the JSON using json.loads(<string here>), grab the values from the dictionary and we publish it using the needed format to a URL.

This is the current code we use to parse the JSON string and expose it (more or less):

someEvent = Model.Objects.all() jsonstring = [] responsedict = {}

for each_entry in someEvent: temp = [] cur_val = json.loads(each_entry.event_data) <- This is already in JSON format for value in cur_val.values(): temp.append(value) jsonstring.append(temp) data["data"] = jsonstring return httpresponse(json.dumps(data), content_type="application/json")

This manual fix works for us to expose the data and grab it using the pure jquery.dataTables using it as ajax datasource (http://www.datatables.net/examples/data_sources/ajax.html) but we would like to integrate with your application since you already handle the serverSide processing.

Would it be possible to add an option on get_context_data to parse out the strings from a single fields instead of using a set of columns?

Comments (2)

  1. Log in to comment