def unicode_or_json_validator(value, context):
 try:
  if (value is None):
   return value
  v = json_validator(value, context)
  if (not isinstance(v, dict)):
   return unicode(value)
  else:
   return v
 except df.Invalid:
  return unicode(value)

def unicode_or_json_validator ( value , context ) : try : if ( value is None ) : return value v = json_validator ( value , context ) if ( not isinstance ( v , dict ) ) : return unicode ( value ) else : return v except df . Invalid : return unicode ( value )
return a parsed json object when applicable .