source: EcnlProtoTool/trunk/mrbgems/mruby-iijson/README.md@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

File size: 2.9 KB
Line 
1# mruby-iijson
2[![Build Status](https://travis-ci.org/iij/mruby-iijson.svg?branch=master)](https://travis-ci.org/iij/mruby-iijson)
3
4"mruby-iijson" is JSON module for mruby.
5
6
7## Implemented Methods:
8 - [JSON.dump](http://docs.ruby-lang.org/en/2.2.0/JSON.html#method-i-dump)
9 - [JSON.generate](http://docs.ruby-lang.org/en/2.2.0/JSON.html#method-i-generate)
10 - [JSON.load](http://docs.ruby-lang.org/en/2.2.0/JSON.html#method-i-load)
11 - [JSON.parse](http://docs.ruby-lang.org/en/2.2.0/JSON.html#method-i-parse)
12 - `Array#to_json`, `Fixnum#to_json`, `Float#to_json`, `Hash#to_json`, `String#to_json`, ...
13
14## Example:
15
16```Ruby
17str = '{
18 "Image": {
19 "Width": 800,
20 "Height": 600,
21 "Title": "View from 15th Floor",
22 "Thumbnail": {
23 "Url": "http://www.example.com/image/481989943",
24 "Height": 125,
25 "Width": "100"
26 },
27 "IDs": [116, 943, 234, 38793]
28 }
29}'
30p JSON.parse(str)
31
32h = {
33 :precision => "zip",
34 :Latitude => 37.7668,
35 :Longitude => -122.3959,
36 :Address => "",
37 :City => "SAN FRANCISCO",
38 :State => "CA",
39 :Zip => "94107",
40 :Country => "US"
41}
42p h.to_json
43puts JSON.generate(h, {:pretty_print => true, :indent_with => 2})
44```
45
46```
47{"Image"=>{"Width"=>800, "Height"=>600, "Title"=>"View from 15th Floor", "Thumbnail"=>{"Url"=>"http://www.example.com/image/481989943", "Height"=>125, "Width"=>"100"}, "IDs"=>[116, 943, 234, 38793]}}
48"{\"precision\":\"zip\",\"Latitude\":37.766800000000003,\"Longitude\":-122.3959,\"Address\":\"\",\"City\":\"SAN FRANCISCO\",\"State\":\"CA\",\"Zip\":\"94107\",\"Country\":\"US\"}"
49{
50 "precision": "zip",
51 "Latitude": 37.766800000000003,
52 "Longitude": -122.3959,
53 "Address": "",
54 "City": "SAN FRANCISCO",
55 "State": "CA",
56 "Zip": "94107",
57 "Country": "US"
58}
59```
60
61
62## Caveats
63
64 - JSON.generate won't return if input Array/Hash has circular reference.
65
66
67## License
68
69Copyright (c) 2014 Internet Initiative Japan Inc.
70
71Permission is hereby granted, free of charge, to any person obtaining a
72copy of this software and associated documentation files (the "Software"),
73to deal in the Software without restriction, including without limitation
74the rights to use, copy, modify, merge, publish, distribute, sublicense,
75and/or sell copies of the Software, and to permit persons to whom the
76Software is furnished to do so, subject to the following conditions:
77
78The above copyright notice and this permission notice shall be included in
79all copies or substantial portions of the Software.
80
81THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
82IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
83FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
84AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
85LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
86FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
87DEALINGS IN THE SOFTWARE.
Note: See TracBrowser for help on using the repository browser.