hendisantika / json-io

Automatically exported from code.google.com/p/json-io
0 stars 1 forks source link

JsonWriter.objectToJson breaks on HashMap<Double, Double> #22

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

public class Console {

    HashMap<Double, Double> hm = new HashMap<Double, Double>();

    public Console() {
        hm.put(345.0, 453.0);
    }

    public static void main(String arg[]) {
        Console c = new Console();

        String s;
        try {
            HashMap<String, Object> args = new HashMap<>();
            args.put(JsonWriter.PRETTY_PRINT, true);

            s = JsonWriter.objectToJson(c, args);

            System.out.println(s);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}

What is the expected output? What do you see instead?

json string is expected, insdead it gives exception:
Exception in thread "main" java.lang.ClassCastException: java.lang.Double 
cannot be cast to java.lang.String

What version of the product are you using? On what operating system?

2.7.1

Please provide any additional information below.

I guess it should be easy to fix, HashMap<Integer, Double> works fine...

Original issue reported on code.google.com by sga...@gmail.com on 1 Nov 2014 at 1:58