回答編集履歴

2

テキスト追加

2018/01/22 17:45

投稿

jun68ykt
jun68ykt

スコア9058

test CHANGED
@@ -44,7 +44,7 @@
44
44
 
45
45
 
46
46
 
47
- ```json
47
+ ```ruby
48
48
 
49
49
  blue_json_text = JSON.pretty_generate(blue_data)
50
50
 

1

テキスト追加

2018/01/22 17:45

投稿

jun68ykt
jun68ykt

スコア9058

test CHANGED
@@ -37,3 +37,59 @@
37
37
 
38
38
 
39
39
  > [{"date"=>"20170101", "title"=>"aiueo", "team_code"=>"blue", "sub_team_code"=>"yellow"}, {"date"=>"20170104", "title"=>"tatitsuteto", "team_code"=>"blue", "sub_team_code"=>"yellow"}]
40
+
41
+
42
+
43
+ さらに、`blue_data` を、見やすいJSON形式の文字列にするには、
44
+
45
+
46
+
47
+ ```json
48
+
49
+ blue_json_text = JSON.pretty_generate(blue_data)
50
+
51
+ ```
52
+
53
+
54
+
55
+ とします。上記の `blue_json_text` を `puts blue_json_text` で表示すると、
56
+
57
+
58
+
59
+ ```json
60
+
61
+ [
62
+
63
+ {
64
+
65
+ "date": "20170101",
66
+
67
+ "title": "aiueo",
68
+
69
+ "team_code": "blue",
70
+
71
+ "sub_team_code": "yellow"
72
+
73
+ },
74
+
75
+ {
76
+
77
+ "date": "20170104",
78
+
79
+ "title": "tatitsuteto",
80
+
81
+ "team_code": "blue",
82
+
83
+ "sub_team_code": "yellow"
84
+
85
+ }
86
+
87
+ ]
88
+
89
+ ```
90
+
91
+ と表示されると思います。
92
+
93
+
94
+
95
+ 以上参考になれば幸いです。