summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/json/lib/json/common.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
index a9682b94cf..ea15b70686 100644
--- a/ext/json/lib/json/common.rb
+++ b/ext/json/lib/json/common.rb
@@ -167,6 +167,13 @@ module JSON
# system. Usually this means that the iconv library is not installed.
class MissingUnicodeSupport < JSONError; end
+ # Fragment of JSON document that is to be included as is:
+ # fragment = JSON::Fragment.new("[1, 2, 3]")
+ # JSON.generate({ count: 3, items: fragments })
+ #
+ # This allows to easily assemble multiple JSON fragments that have
+ # been peristed somewhere without having to parse them nor resorting
+ # to string interpolation.
Fragment = Struct.new(:json) do
def to_json(state = nil, *)
json