From bcc5ac8d5d0477a2e65bc3f37e39c3ba35071175 Mon Sep 17 00:00:00 2001 From: tbpgr Date: Mon, 26 Nov 2018 00:14:36 +0900 Subject: [PATCH 1/2] Add sample code of JSON.generate --- refm/api/src/json/JSON | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/refm/api/src/json/JSON b/refm/api/src/json/JSON index 561f5e4a00..b8364c87d9 100644 --- a/refm/api/src/json/JSON +++ b/refm/api/src/json/JSON @@ -127,6 +127,16 @@ unparse は将来削除される予定です。 @raise JSON::CircularDatastructure 与えられたオブジェクトが循環参照を持つ場合に発生します。 +#@samplecode 例 +require "json" + +JSON.generate([1, 2, { name: "tanaka", age: 19 }]) +# => "[1,2,{\"name\":\"tanaka\",\"age\":19}]" +json_state = JSON::State.new(space: "@") +JSON.generate([1, 2, { name: "tanaka", age: 19 }], json_state) +# => "[1,2,{\"name\":@\"tanaka\",\"age\":@19}]" +#@end + @see [[c:JSON::State]], [[m:JSON.#pretty_generate]] --- load(source, proc = nil, options = {}) -> object From 0a7e8f6b2d357a82333c526c5a16ff10e2195b40 Mon Sep 17 00:00:00 2001 From: Seiei Miyagi Date: Tue, 4 Feb 2020 20:53:07 +0900 Subject: [PATCH 2/2] =?UTF-8?q?JSON.generate=E3=81=AB=E6=B8=A1=E3=81=99JSO?= =?UTF-8?q?N::State=E3=81=AEspace=E3=82=AA=E3=83=97=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=92`@`=E3=81=8B=E3=82=89`=20`=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E3=81=88=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- refm/api/src/json/JSON | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/refm/api/src/json/JSON b/refm/api/src/json/JSON index b8364c87d9..2f6cb026f3 100644 --- a/refm/api/src/json/JSON +++ b/refm/api/src/json/JSON @@ -132,9 +132,9 @@ require "json" JSON.generate([1, 2, { name: "tanaka", age: 19 }]) # => "[1,2,{\"name\":\"tanaka\",\"age\":19}]" -json_state = JSON::State.new(space: "@") +json_state = JSON::State.new(space: " ") JSON.generate([1, 2, { name: "tanaka", age: 19 }], json_state) -# => "[1,2,{\"name\":@\"tanaka\",\"age\":@19}]" +# => "[1,2,{\"name\": \"tanaka\",\"age\": 19}]" #@end @see [[c:JSON::State]], [[m:JSON.#pretty_generate]]