Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Switch to multi_json lib

  • Loading branch information...
commit 3097959f64b30d69d6631ee1ff9ca90e1ad8d830 1 parent 8701188
@josh josh authored
Showing with 5 additions and 4 deletions.
  1. +1 −0  execjs.gemspec
  2. +4 −4 lib/execjs/external_runtime.rb
View
1  execjs.gemspec
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
"README.md"
]
+ s.add_dependency "multi_json", ">=1.0.0"
s.add_development_dependency "mustang"
s.add_development_dependency "therubyracer"
s.add_development_dependency "therubyrhino"
View
8 lib/execjs/external_runtime.rb
@@ -1,4 +1,3 @@
-require "json"
require "tempfile"
module ExecJS
@@ -11,7 +10,7 @@ def initialize(runtime, source = "")
def eval(source, options = {})
if /\S/ =~ source
- exec("return eval(#{"(#{source})".to_json})")
+ exec("return eval(#{MultiJson.encode("(#{source})")})")
end
end
@@ -22,7 +21,7 @@ def exec(source, options = {})
end
def call(identifier, *args)
- eval "#{identifier}.apply(this, #{args.to_json})"
+ eval "#{identifier}.apply(this, #{MultiJson.encode(args)})"
end
protected
@@ -47,7 +46,7 @@ def compile(source)
end
def extract_result(output)
- status, value = output.empty? ? [] : JSON.parse(output)
+ status, value = output.empty? ? [] : MultiJson.decode(output)
if status == "ok"
value
else
@@ -83,6 +82,7 @@ def compile(source)
end
def available?
+ require "multi_json"
@binary ? true : false
end
Please sign in to comment.
Something went wrong with that request. Please try again.