0
我有一个Java类,我想从类的对象生成一个JSON字符串。然而,是类的成员如下:Java flexjson序列化组成的JSON对象
/**
* The set containing the footer texts
*/
public HeaderOrFooter[] footers = null;
/**
* The title of the word cloud
*/
public HeaderOrFooter title;
/**
* The subtitle of the word cloud
*/
public HeaderOrFooter subTitle;
/**
* The set of rectangles to be drawn
*/
public Rectangle[] rectangles;
/**
* The set of round rectangles to be drawn
*/
public RoundRectangle[] roundRectangles;
/**
* The set of lines to be drawn
*/
public Line[] lines;
/**
* The set of polygons to be drawn
*/
public Polygon[] polygons;
/**
* The set of words to be drawn
*/
public Word[] words;
和我的方法,其将该对象JSON是这样的:
public String convertToJSON()
{
flexjson.JSONSerializer jsonSerializer = new flexjson.JSONSerializer();
jsonSerializer.exclude("class");
jsonSerializer.exclude("subTitle.class");
jsonSerializer.exclude("title.class");
return jsonSerializer.serialize(this);
}
我使用flexjson
及其JSONSerializer
对象。我的问题是,它只将标题和子标题成员转换为JSON,数组不转换。有人能告诉我如何将数组包括到我的JSON中?谢谢。
你给了整个阵列,'新线[1]'或者类似的东西值?之后,你填写'Line'对象。 – 2013-05-06 22:36:46
阵列充满了价值。我可以分别序列化它们,但是我想从包含它们的对象中生成JSON。 – 2013-05-07 00:01:09