本文整理匯總了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();
}