mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Move Parsing JSON to Docs page
This commit is contained in:
parent
43fafbf88d
commit
41a90a7218
2 changed files with 9 additions and 8 deletions
|
@ -47,14 +47,6 @@ puts stack_exchange.users
|
||||||
|
|
||||||
See the [examples directory](http://github.com/jnunemaker/httparty/tree/master/examples) for even more goodies.
|
See the [examples directory](http://github.com/jnunemaker/httparty/tree/master/examples) for even more goodies.
|
||||||
|
|
||||||
## JSON Parsing
|
|
||||||
If the response Content Type is `application/json`, HTTParty will parse the response and return Ruby objects such as a hash or array. The default behavior for parsing JSON will return keys as strings. This can be supressed with the `format` option. To get hash keys as symbols:
|
|
||||||
|
|
||||||
```
|
|
||||||
response = HTTParty.get('http://example.com', format: :plain)
|
|
||||||
JSON.parse response, symbolize_names: true
|
|
||||||
```
|
|
||||||
|
|
||||||
## Command Line Interface
|
## Command Line Interface
|
||||||
|
|
||||||
httparty also includes the executable `httparty` which can be
|
httparty also includes the executable `httparty` which can be
|
||||||
|
|
|
@ -3,8 +3,17 @@
|
||||||
Makes http fun again!
|
Makes http fun again!
|
||||||
|
|
||||||
## Table of contents
|
## Table of contents
|
||||||
|
- [Parsing JSON](#parsing-json)
|
||||||
- [Working with SSL](#working-with-ssl)
|
- [Working with SSL](#working-with-ssl)
|
||||||
|
|
||||||
|
## Parsing JSON
|
||||||
|
If the response Content Type is `application/json`, HTTParty will parse the response and return Ruby objects such as a hash or array. The default behavior for parsing JSON will return keys as strings. This can be supressed with the `format` option. To get hash keys as symbols:
|
||||||
|
|
||||||
|
```
|
||||||
|
response = HTTParty.get('http://example.com', format: :plain)
|
||||||
|
JSON.parse response, symbolize_names: true
|
||||||
|
```
|
||||||
|
|
||||||
## Working with SSL
|
## Working with SSL
|
||||||
|
|
||||||
You can use this guide to work with SSL certificates.
|
You can use this guide to work with SSL certificates.
|
||||||
|
|
Loading…
Add table
Reference in a new issue