Last active
March 28, 2024 09:59
-
-
Save mderazon/9729626 to your computer and use it in GitHub Desktop.
Revisions
-
mderazon revised this gist
Mar 23, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,11 +16,11 @@ var obj = { "venue_location": { "en": "Baker St.", "he": "רחוב האופה" }, "venue_name": { "en": "Aroma Coffee", "he": "קפה ארומה" } }; console.log(filter_language('en', obj)); -
mderazon created this gist
Mar 23, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ var traverse = require('traverse'); // filter json obj by language var filter_language = function(language, obj) { var result = traverse(obj).map(function(item) { if (this.key === language) { this.parent.update(item); } }); return result; }; // example object in the multi-lingual format var obj = { "venue_id": "C001", "venue_location": { "en": "Baker St.", "he": "רחוב האופה" } "venue_name": { "en": "Aroma Coffee", "he": "קפה ארומה" } } console.log(filter_language('en', obj));