mathewdenis / json-smart

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

javabean JSR , boolean property isnot right. #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. JavaBean  , boolean isPopping 
2. json-smart outputs
3.

What is the expected output? What do you see instead?
Just like Eclipse IDE generates codes.
    public boolean isPopping() {
        return isPopping;
    }

What version of the product are you using? On what operating system?
json-smart-1.1.1

Please provide any additional information below.

Original issue reported on code.google.com by linzuxio...@gmail.com on 5 Jun 2012 at 8:24

GoogleCodeExporter commented 9 years ago
I do not see any problem here,
I have just add 2 more JUnit test to check boolean isValue() and getValue(), 
both of them works.

Original comment by uriel.chemouni on 23 Jun 2012 at 4:27

GoogleCodeExporter commented 9 years ago
public class Mo {
    boolean isPopping;

    public boolean isPopping() {
        return isPopping;
    }

    public void setPopping(boolean isPopping) {
        this.isPopping = isPopping;
    }

    public static void main(String[] args) {
        Mo mo = new Mo();
        mo.setPopping(false);

        JSONObject data = new JSONObject();
        data.put("mo", mo);
        System.out.println(data.toJSONString());
    }

}

Exception in thread "main" java.lang.RuntimeException: 
java.lang.NoSuchMethodException: org.json.tes
t.Mo.isIsPopping()
    at net.minidev.json.JSONValue.writeJSONString(JSONValue.java:625)
    at net.minidev.json.JSONObject.writeJSONKV(JSONObject.java:102)
    at net.minidev.json.JSONObject.writeJSON(JSONObject.java:169)
    at net.minidev.json.JSONObject.toJSONString(JSONObject.java:72)
    at net.minidev.json.JSONObject.toJSONString(JSONObject.java:249)
    at org.json.test.Mo.main(Mo.java:22)
Caused by: java.lang.NoSuchMethodException: org.json.test.Mo.isIsPopping()
    at java.lang.Class.getDeclaredMethod(Class.java:1937)
    at net.minidev.json.JSONValue.writeJSONString(JSONValue.java:610)
    ... 5 more

Original comment by linzuxio...@gmail.com on 12 Jul 2012 at 6:01

GoogleCodeExporter commented 9 years ago
Mo is not a valid beans,
Mo class should be:

public class Mo {
    boolean popping;

    public boolean isPopping() {
        return isPopping;
    }

    public void setPopping(boolean popping) {
        this.isPopping = popping;
    }

    public static void main(String[] args) {
        Mo mo = new Mo();
        mo.setPopping(false);

        JSONObject data = new JSONObject();
        data.put("mo", mo);
        System.out.println(data.toJSONString());
    }

}

Original comment by uriel.chemouni on 29 Oct 2012 at 1:35