Created
March 18, 2010 17:23
-
-
Save glurp/336594 to your computer and use it in GitHub Desktop.
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 characters
static public Object to_jsonnable(Object o) { | |
if (o instanceof List) { | |
List lo = (List)o; | |
ArrayList nlo = new ArrayList(); | |
for (Object a : lo) nlo.add(to_jsonnable(a)) ; | |
return(nlo); | |
} else if (o instanceof Map) { | |
Map mo = (Map)o; | |
LinkedHashMap<Object, Object> nmo = | |
new LinkedHashMap<Object, Object>(); | |
for (Object a : mo.entrySet() ) { | |
Map.Entry me = (Map.Entry)a; | |
nmo.put(me.getKey().toString(),to_jsonnable(me.getValue())); | |
} | |
return(nmo); | |
} else if (o instanceof RubyNumeric) | |
return(o) ; | |
else | |
return(o.toString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment