0

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' 
        } 
    ] 
],

}
3
  • Are you finding simplejson does not have adequate performance for certain cases? If so, can you elaborate on which ones and what your performance goal is (a bit more quantitatively)? Commented Oct 30, 2010 at 22:44
  • What's wrong with that solution? Commented Oct 31, 2010 at 0:33
  • I started with JSONpickle and it was slower then simplejson -- I was concerned that about: 1.) the speed of the parsing routine 2.) the consistncy of the data structure (when there are more of an "entity" objects, does the simplejson still use the same data structure?) 3.) do i need to do my own parser for optimum performance? 4.) should i just set up a timeit object in a test program to time the parsing of my data structure acorss libraries? Commented Oct 31, 2010 at 12:55

1 Answer 1

5

Um...

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

?

Sign up to request clarification or add additional context in comments.

1 Comment

I keep getting errors in the simplejson parsing routine when I try to serialize it using "loads" method. Is there a way I can force a certain way to serialize the objects in my data class?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.