Class RhinoUtils
This class can be used directly in Rhino.
This class was inspired from http://mongodb-rhino.googlecode.com/svn/trunk/modules/com.mongodb.rhino/src/com/mongodb/rhino/JSON.java
- Since:
- 1.3.6
- Author:
- Alex Objelean
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateExceptionMessage(org.mozilla.javascript.RhinoException e) Creates a more detailed message based onRhinoExceptionthrown by rhino execution.static StringRecursively convert from native Rhino to JSON.static StringRecursively convert from native Rhino to JSON.
-
Method Details
-
createExceptionMessage
Creates a more detailed message based onRhinoExceptionthrown by rhino execution. The message will contain a detailed description of the problem by inspecting the JSON value provided by exception.- Parameters:
e-RhinoExceptionthrown by rhino execution.- Returns:
- detailed string message.
-
toJson
Recursively convert from native Rhino to JSON.Recognizes JavaScript objects, arrays and primitives.
Special support for JavaScript dates: converts to {"$date": timestamp} in JSON.
Special support for MongoDB ObjectId: converts to {"$oid": "objectid"} in JSON.
Also recognizes JVM types: java.util.Map, java.util.Collection, java.util.Date.
- Parameters:
object- A Rhino native object- Returns:
- The JSON string
-
toJson
Recursively convert from native Rhino to JSON.Recognizes JavaScript objects, arrays and primitives.
Special support for JavaScript dates: converts to {"$date": timestamp} in JSON.
Special support for MongoDB ObjectId: converts to {"$oid": "objectid"} in JSON.
Also recognizes JVM types: java.util.Map, java.util.Collection, java.util.Date.
- Parameters:
object- A Rhino native objectindent- Whether to indent the JSON for human readability- Returns:
- The JSON string
-