lib/avro/builder/dsl.rb in avro-builder-0.17.0 vs lib/avro/builder/dsl.rb in avro-builder-1.0.0
- old
+ new
@@ -1,8 +1,9 @@
# frozen_string_literal: true
require 'avro'
+require 'multi_json'
require 'avro/builder/errors'
require 'avro/builder/dsl_options'
require 'avro/builder/dsl_attributes'
require 'avro/builder/namespaceable'
require 'avro/builder/definition_cache'
@@ -75,10 +76,10 @@
end
# Return the last schema object processed as an Avro JSON schema
def to_json(validate: true, pretty: true)
hash = to_h
- (pretty ? JSON.pretty_generate(hash) : hash.to_json).tap do |json|
+ MultiJson.dump(hash, { pretty: pretty }).tap do |json|
# Uncomment the next line to debug:
# puts json
# Parse the schema to validate before returning
::Avro::Schema.parse(json) if validate
end