Skip to content

Instantly share code, notes, and snippets.

@ZeroPivot
Created August 4, 2021 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZeroPivot/0b5c1e20d454ade98d420407ebdb92c4 to your computer and use it in GitHub Desktop.
Save ZeroPivot/0b5c1e20d454ade98d420407ebdb92c4 to your computer and use it in GitHub Desktop.
# rubocop:disable Style/StringLiterals
# rubocop:disable Style/FrozenStringLiteralComment
# rubocop:disable Lint/RedundantCopDisableDirective
# rubocop:disable Layout/TrailingEmptyLines
# rubocop:disable Lint/RedundantCopDisableDirective
# rubocop:disable Layout/EmptyLines
require 'json'
require_relative 'aoh'
# Converts some string to JSON format, mostly for usage in the DragonRuby toolkit
class String2JSON
def initialize
aoh
end
def string2json(json_string)
end
def array_of_hashes
end
def something
end
end
def parse_string(hash)
u_string = hash.to_s
u_string.gsub! "=>", ":"
u_string.gsub! '"', '\\"'
u_string.gsub! "nil", "null"
end
#parse_string({ "lol" => 2, "rofl" => "hehe", "hehe" => nil })
database = AOH.new
100.times do
database.add({"nil" => nil, "number" => 2.0, "number2" => "5"})
end
puts database.collection.to_s
json = parse_string(database.collection)
p json.to_json
#parse_string(database.collection_get)
# rubocop:enable Style/FrozenStringLiteralComment
# rubocop:enable Layout/EmptyLines
# rubocop:enable Lint/RedundantCopDisableDirective
# rubocop:enable Layout/TrailingEmptyLines
# rubocop:enable Lint/RedundantCopDisableDirective
# rubocop:enable Style/StringLiterals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment