mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Replace multi_json with json
This commit is contained in:
parent
79698e8bc6
commit
6548dab51f
2 changed files with 5 additions and 28 deletions
|
@ -16,7 +16,7 @@ module ExecJS
|
||||||
source = encode(source)
|
source = encode(source)
|
||||||
|
|
||||||
if /\S/ =~ source
|
if /\S/ =~ source
|
||||||
exec("return eval(#{JSON.encode("(#{source})")})")
|
exec("return eval(#{::JSON.dump("(#{source})")})")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ module ExecJS
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(identifier, *args)
|
def call(identifier, *args)
|
||||||
eval "#{identifier}.apply(this, #{JSON.encode(args)})"
|
eval "#{identifier}.apply(this, #{::JSON.dump(args)})"
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
@ -50,7 +50,7 @@ module ExecJS
|
||||||
end
|
end
|
||||||
output.sub!('#{encoded_source}') do
|
output.sub!('#{encoded_source}') do
|
||||||
encoded_source = encode_unicode_codepoints(source)
|
encoded_source = encode_unicode_codepoints(source)
|
||||||
JSON.encode("(function(){ #{encoded_source} })()")
|
::JSON.dump("(function(){ #{encoded_source} })()")
|
||||||
end
|
end
|
||||||
output.sub!('#{json2_source}') do
|
output.sub!('#{json2_source}') do
|
||||||
IO.read(ExecJS.root + "/support/json2.js")
|
IO.read(ExecJS.root + "/support/json2.js")
|
||||||
|
@ -59,7 +59,7 @@ module ExecJS
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_result(output)
|
def extract_result(output)
|
||||||
status, value = output.empty? ? [] : JSON.decode(output)
|
status, value = output.empty? ? [] : ::JSON.load(output)
|
||||||
if status == "ok"
|
if status == "ok"
|
||||||
value
|
value
|
||||||
elsif value =~ /SyntaxError:/
|
elsif value =~ /SyntaxError:/
|
||||||
|
@ -100,7 +100,7 @@ module ExecJS
|
||||||
end
|
end
|
||||||
|
|
||||||
def available?
|
def available?
|
||||||
require "execjs/json"
|
require 'json'
|
||||||
binary ? true : false
|
binary ? true : false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
require "multi_json"
|
|
||||||
|
|
||||||
module ExecJS
|
|
||||||
module JSON
|
|
||||||
if MultiJson.respond_to?(:dump)
|
|
||||||
def self.decode(obj)
|
|
||||||
MultiJson.load(obj)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.encode(obj)
|
|
||||||
MultiJson.dump(obj)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
def self.decode(obj)
|
|
||||||
MultiJson.decode(obj)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.encode(obj)
|
|
||||||
MultiJson.encode(obj)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue