# angular.formatter.json

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

## Description

Formats the user input as JSON text.

## Usage

### In HTML Template Binding

    <input type="text" name="bindExpression" ng:format="json">

### In JavaScript

    var userInputString = angular.formatter.json.format(modelValue);
    var modelValue = angular.formatter.json.parse(userInputString);

### Returns

`{?string}` –

A JSON string representation of the model.

## Example

     <div ng:init="data={name:'misko', project:'angular'}">
       <input type="text" size='50' name="data" ng:format="json"/>
       <pre>data={{data}}</pre>
     </div>

     it('should format json', function(){
       expect(binding('data')).toEqual('data={\n  \"name\":\"misko\",\n  \"project\":\"angular\"}');
       input('data').enter('{}');
       expect(binding('data')).toEqual('data={\n  }');
     });