我有一個Java的HashMap,我在JRuby中JSON,我試圖將其轉換爲JSON,但它無法正常轉換,我覺得這個例子說明這個問題:如何映射到Java轉換JRuby中
$ irb [17:23:50]
irb(main):001:0> require 'java'
=> false
irb(main):003:0> require 'json'
=> true
irb(main):005:0> h = java.util.HashMap.new()
=> {}
irb(main):006:0> x = {}
=> {}
irb(main):007:0> JSON.parse JSON.dump x
=> {}
irb(main):008:0> JSON.parse JSON.dump h
JSON::ParserError: unexpected token at '"{}"'
from json/ext/Parser.java:251:in `parse'
from /Users/kimptoc/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/json/common.rb:155:in `parse'
from (irb):9:in `evaluate'
from org/jruby/RubyKernel.java:1066:in `eval'
from org/jruby/RubyKernel.java:1409:in `loop'
from org/jruby/RubyKernel.java:1174:in `catch'
from org/jruby/RubyKernel.java:1174:in `catch'
from /Users/kimptoc/.rvm/rubies/jruby-1.7.3/bin/irb:13:in `(root)'
irb(main):010:0> JSON.dump h
=> "\"{}\""
關於如何處理這個任何想法 - 我需要把地圖變成一個Ruby地圖?
謝謝, 克里斯