I’m new to python and django. Needed to determine if an object was of type JSON.

Here’s how I did it in python:

#
# Tries to parse jsonstring
# @param: {string} jsonstring
# @return: {dict or string}
#
def get_obj( jsonstring ):  
    try:
        data = simplejson.loads( jsonstring )
        return data
    exception ValueError:
        return []

#
# Determines if data is JSON
# @param: {string} data
# @return: {boolean}
#
def is_obj( data ):  
    return ( ( type(data) == dict ) & ( len(data) > 0 ) )