views:

33

answers:

1

JSON serialization Python using simpleJSON

How do I create an object so that we can optimize the serialization of the object

I'm using simpleJSON

1,2 are fixed variables

3 is a fixed dict of category and score

4 is an array of dicts that are fixed in length (4), the array is a length specificed at run-time.

The process needs to be as fast as possible, so I'm not sure about the best solution.

    {
    "always-include": true,
    "geo": null,
    "category-score" : [
        {
            "Arts-Entertainment": 0.72,
            "Business": 0.03,
            "Computers-Internet": 0.08,
            "Gaming": 0.02,
            "Health": 0.02,

        } 
    ],
    "discovered-entities" : [
        {
            'relevance': '0.410652',
            'count': '2',
            'type': 'TelevisionStation',
            'text': 'Fox News' 
        },
        {
            'relevance': '0.396494',
            'count': '2',
            'type': 'Organization',
            'text': 'NBA' 
        } 
    ] 
],

}
+2  A: 

Um...

import simplejson as json
result_object = json.loads(input_json_string)

?

Amber