angular.filter.json

Work in Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

Description

Allows you to convert a JavaScript object into JSON string.

This filter is mostly useful for debugging. When using the double curly {{value}} notation the binding is automatically converted to JSON.

Usage

In HTML Template Binding

{{ json_expression | json }}

In JavaScript

angular.filter.json(object)

Parameters

Returns

{string}

JSON string.

Example

  <pre>{{ {'name':'value'} | json }}</pre>
  it('should jsonify filtered objects', function() {
    expect(binding('| json')).toBe('{\n  "name":"value"}');
  });