https://github.com/yankeguo-deprecated/json_wrapper
SwiftyJSON inspired JSON lib for Ruby
https://github.com/yankeguo-deprecated/json_wrapper
Last synced: about 2 months ago
JSON representation
SwiftyJSON inspired JSON lib for Ruby
- Host: GitHub
- URL: https://github.com/yankeguo-deprecated/json_wrapper
- Owner: yankeguo-deprecated
- License: mit
- Created: 2015-12-02T14:51:53.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-30T08:51:05.000Z (over 9 years ago)
- Last Synced: 2025-02-14T16:58:30.494Z (3 months ago)
- Language: Ruby
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json_wrapper
SwiftyJSON inspired JSON lib for Ruby, very handy for JSON parsing and access while incoming JSON structure is not definite.
# Usage
```ruby
# {
# "key_a": 1,
# "key_b": "2",
# "key_c": [ 1 ],
# "key_d": {
# "a": 1
# }
# }raw_json = JSON.parse File.open("sample.json").read
json = JsonWrapper.new raw_jsonjson[:key_a].number? == true
json[:key_a].number == 1
json[:key_a].string == nil
json[:key_a].string! == "1"json.kay_a.number? == true
json.key_a.number == 1
json.key_a.string == nil
json.kay_a.string! == "1"json[:key_a][:key_not_exists].string == nil
json[:key_a][:key_not_exists].string! == ""```
`JsonWrapper` supports `Enumerator` methods.
# LICENSE
See 'LICENSE', basically MIT license.