Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: recipe_modules/json/api.py

Issue 2798393002: Work around unicode issues by re-encoding properties as utf-8 (Closed)
Patch Set: comment Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_engine/util.py ('k') | recipes.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_modules/json/api.py
diff --git a/recipe_modules/json/api.py b/recipe_modules/json/api.py
index 812f71ad459db1ca8ec72a7163cc0bfa8f17afd8..8b9802d2894eb9a7a18c6a32b31366e8701a2af9 100644
--- a/recipe_modules/json/api.py
+++ b/recipe_modules/json/api.py
@@ -82,21 +82,7 @@ class JsonApi(recipe_api.RecipeApi):
@classmethod
def loads(self, data, **kwargs):
- def strip_unicode(obj):
- if isinstance(obj, unicode):
- return obj.encode('utf-8', 'replace')
-
- if isinstance(obj, list):
- return map(strip_unicode, obj)
-
- if isinstance(obj, dict):
- new_obj = type(obj)(
- (strip_unicode(k), strip_unicode(v)) for k, v in obj.iteritems() )
- return new_obj
-
- return obj
-
- return strip_unicode(json.loads(data, **kwargs))
+ return recipe_util.strip_unicode(json.loads(data, **kwargs))
def is_serializable(self, obj):
"""Returns True if the object is JSON-serializable."""
« no previous file with comments | « recipe_engine/util.py ('k') | recipes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698