Last active
August 29, 2015 13:56
-
-
Save ratpik/8914193 to your computer and use it in GitHub Desktop.
De-serialize json stored as unicode back to JSON for Tastypie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json, ast | |
def dehydrate_metadata(self, bundle): | |
metadata_dict = ast.literal_eval(bundle.data['metadata']) | |
metadata_dict_str = dict([(str(k), str(v)) for k, v in metadata_dict.items()]) | |
return json.dumps(metadata_dict_str) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment