Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stratedge/lumen-pretty-json

A clean and simple way to have JSON output through Lumen's ResponseFactory class use JSON_PRETTY_PRINT by default
https://github.com/stratedge/lumen-pretty-json

Last synced: 5 days ago
JSON representation

A clean and simple way to have JSON output through Lumen's ResponseFactory class use JSON_PRETTY_PRINT by default

Awesome Lists containing this project

README

        

# lumen-pretty-json

A clean and simple way to have JSON output through Lumen's ResponseFactory class use JSON_PRETTY_PRINT by default. No requirement to pass a status and headers just to then set the JSON option for JSON_PRETTY_PRINT. Handy for APIs where all the returned content is JSON.

## Usage Examples

### Instantiating The ResponseFactory
```
json([
"id" => 10,
"first_name" => "Abraham",
"last_name" => "Lincoln"
]);
}

```

### Injecting the ResponseFactory
```
json([
"id" => 10,
"first_name" => "Abraham",
"last_name" => "Lincoln"
]);
}
```

## Output
In browsers like Chrome, using the combination of JSON_PRETTY_PRINT and the application/json content type, output will display in a more readable fashion, without any additional markup:

```
{
"id": 10,
"first_name": "Abraham",
"last_name": "Lincoln"
}
```