Documentation for a historical release of Infusion: 1.4
Please view the Infusion Documentation site for the latest documentation, or the Infusion 1.3. Documentation for the previous release.
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

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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

Parameters

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

  • [fluid.log]

Example

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