'Gets value for datastore.
Args:
model_instance: instance of the model class.
Returns:
datastore-compatible value.'

def get_value_for_datastore(self, model_instance):

    value = super(JsonProperty, self).get_value_for_datastore(model_instance)
    if (not value):
        return None
    return datastore_types.Text(simplejson.dumps(value.to_json(), sort_keys=True))
