Child pages
  • fluid.prettyPrintJSON

This documentation is currently being moved to our new documentation site.

Please view or edit the documentation there, instead.

If you're looking for Fluid Project coordination, design, communication, etc, try the Fluid Project Wiki.

Skip to end of metadata
Go to start of metadata

This functionality is Sneak Peek status. This means that the APIs may change. We welcome your feedback, ideas, and code, but please use caution if you use this new functionality.

function.prettyPrintJSON(obj, options)

Convert a JSON object into a nicely spaced text string.

function.prettyPrintJSON(obj, options);

File name: FluidDebugging.js


obj (Object) The JSON object to print
options (Object) (optional) Options configuring how the string is produced. The options will be passed on to JSON.stringify().

Return Value

String A string representation of the JSON object.

See Also


var myObject = {
    arr1: ["foo", "bar"],
    obj1: {
        subObj1: "Foo",
        subObj2: "Bar"
var string = fluid.prettyPrintJSON(myObject);

In this example, the results string will contain

"{\n    arr1: [\"foo\", \"bar\"],\n    obj1: {\n        subObj1: \"Foo\",\n        subObj2: \"Bar\"\n    }\n}"

which, when output, would produce

    arr1: ["foo", "bar"],
    obj1: {
        subObj1: "Foo",
        subObj2: "Bar"
  • No labels