Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sample code of JSON.generate #1629

Merged
merged 2 commits into from Feb 4, 2020

Conversation

@sho-h

This comment has been minimized.

Copy link
Member

sho-h commented Jan 4, 2019

先にstateを指定しない別のサンプルがあるとより読みやすいかもしれません。

@tbpgr tbpgr force-pushed the tbpgr:add_sample_code_of_json_m_generate branch from e6a63f7 to bcc5ac8 Jan 15, 2019
@tbpgr

This comment has been minimized.

Copy link
Contributor Author

tbpgr commented Jan 15, 2019

state をつけないサンプルを追加しました

# => "[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}]"

This comment has been minimized.

Copy link
@hanachin

hanachin Feb 4, 2020

Member

スペースの代わりに @ が使われていてもあんまり嬉しさがない気がします


JSON.generate([1, 2, { name: "tanaka", age: 19 }])
# => "[1,2,{\"name\":\"tanaka\",\"age\":19}]"
json_state = JSON::State.new(space: "@")

This comment has been minimized.

Copy link
@hanachin

hanachin Feb 4, 2020

Member

spaceはデフォルト値で "" のようなので " " のようなJSONとしてパースするのに支障がないスペースを渡してやるのがよさそう

Suggested change
json_state = JSON::State.new(space: "@")
json_state = JSON::State.new(space: " ")
@hanachin hanachin merged commit 5aa0a74 into rurema:master Feb 4, 2020
2 of 8 checks passed
2 of 8 checks passed
rake
Details
misspell
Details
Header rules Deploy failed
Details
Mixed content Deploy failed
Details
Pages changed Deploy failed
Details
Redirect rules Deploy failed
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
deploy/netlify Deploy preview processing.
Details
@tbpgr tbpgr deleted the tbpgr:add_sample_code_of_json_m_generate branch Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.