yuwei5380 / jsonplugin

Automatically exported from code.google.com/p/jsonplugin
0 stars 0 forks source link

jsonplugin-0.33 problem #88

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
i use struts2.1.6 and jsonplugin0.33 for web application. when i use
jsonplugin to serialize pojo for me ,and it return a empty result.
my test programe is listed below.
package controller;

import com.googlecode.jsonplugin.annotations.JSON;
import com.opensymphony.xwork2.ActionSupport;

class Student {
    String stuName;
    int age;
    Student(String s, int age) {
        stuName = s;
        this.age = age;
    }
    void setStuName(String s) {
        stuName = s;
    }
    void setAge(int age) {
        this.age = age;
    }
}

public class jsonAction extends ActionSupport {
    private String name;
    private Student tly;
    public void setName(String s) {
        name = s;
    }
    @JSON(name = "newName")
    public String getName() {
        return name;
    }
    public Student getTly() {
        return tly;
    }
    public String execute() throws Exception {
        tly = new Student("tly", 28);
        System.out.println("inspired by ajax " + name);
        return SUCCESS;
    }
}

i want it return {"newName":"tanleiyu","tly":{"stuName":"tly","age":"28"}}.
but it return {"newName":"tanleiyu","tly":{}} for me.

please kindly tell me how to resolve this problem. it makes me crazy now.

Original issue reported on code.google.com by tanleiyu...@163.com on 16 Mar 2009 at 11:47

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
You need to add getter methods on your Student class. Specifically, you need to 
add
getStuName() and getAge() methods.

Original comment by bsennin...@gmail.com on 2 Jun 2009 at 1:59

GoogleCodeExporter commented 8 years ago

Original comment by musa...@gmail.com on 28 Jul 2009 at 5:07