本文整理汇总了Java中elemental.json.JsonFactory类的典型用法代码示例。如果您正苦于以下问题:Java JsonFactory类的具体用法?Java JsonFactory怎么用?Java JsonFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonFactory类属于elemental.json包,在下文中一共展示了JsonFactory类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toJson
import elemental.json.JsonFactory; //导入依赖的package包/类
@Override
public String toJson() {
JsonFactory factory = new JreJsonFactory();
System.out.println("TO JSON:");
JsonObject json = new JreJsonObject(factory);
try {
json.put("bgColor", backgroundColor);
json.put("fgColor", foregroundColor);
json.put("borderStyle", borderStyle.getStyle());
json.put("borderWidth", borderWidth);
json.put("borderColor", borderColor);
json.put("borderRounded", borderRounded);
JsonArray margins = new JreJsonArray(factory);
for (int i = 0; i < margin.length; i++) {
margins.set(i, margin[i]);
}
json.put("margins", margins);
JsonArray paddings = new JreJsonArray(factory);
for (int i = 0; i < padding.length; i++) {
paddings.set(i, padding[i]);
}
json.put("paddings", paddings);
json.put("fontFamily", fontFamily);
json.put("fontSize", fontSize);
json.put("fontBolded", fontBolded);
json.put("fontItalic", fontItalic);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return json.toString();
}
示例2: fromJson
import elemental.json.JsonFactory; //导入依赖的package包/类
@Override
public void fromJson(String jsonStr) {
System.out.println("FROM JSON:" + jsonStr);
JsonFactory factory = new JreJsonFactory();
try {
JsonObject json = factory.parse(jsonStr);
backgroundColor = json.getString("bgColor");
foregroundColor = json.getString("fgColor");
borderStyle = BorderStyle.getFromStyle(json
.getString("borderStyle"));
borderWidth = (int) json.getNumber("borderWidth");
borderColor = json.getString("borderColor");
borderRounded = (int) json.getNumber("borderRounded");
int[] margins = parseIntJSONArr(json.getArray("margins"));
setMargin(margins[0], margins[1], margins[2], margins[3]);
int[] paddings = parseIntJSONArr(json.getArray("paddings"));
setPadding(paddings[0], paddings[1], paddings[2], paddings[3]);
fontFamily = json.getString("fontFamily");
fontSize = json.getString("fontSize");
fontBolded = json.getBoolean("fontBolded");
fontItalic = json.getBoolean("fontItalic");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: ElementalJsonRpcQualifier
import elemental.json.JsonFactory; //导入依赖的package包/类
@Inject
public ElementalJsonRpcQualifier(JsonFactory jsonFactory) {
this.jsonFactory = jsonFactory;
}
示例4: ElementalJsonRpcUnmarshaller
import elemental.json.JsonFactory; //导入依赖的package包/类
@Inject
public ElementalJsonRpcUnmarshaller(JsonFactory jsonFactory) {
this.jsonFactory = jsonFactory;
}
示例5: ElementalJsonRpcComposer
import elemental.json.JsonFactory; //导入依赖的package包/类
@Inject
public ElementalJsonRpcComposer(JsonFactory jsonFactory, DtoFactory dtoFactory) {
this.jsonFactory = jsonFactory;
this.dtoFactory = dtoFactory;
}
示例6: ElementalJsonRpcMarshaller
import elemental.json.JsonFactory; //导入依赖的package包/类
@Inject
public ElementalJsonRpcMarshaller(JsonFactory jsonFactory, DtoFactory dtoFactory) {
this.jsonFactory = jsonFactory;
this.dtoFactory = dtoFactory;
}
示例7: provideJsonFactory
import elemental.json.JsonFactory; //导入依赖的package包/类
@Provides
@Singleton
protected JsonFactory provideJsonFactory() {
return Json.instance();
}