本文整理匯總了Java中com.eclipsesource.json.JsonObject.add方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonObject.add方法的具體用法?Java JsonObject.add怎麽用?Java JsonObject.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.eclipsesource.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: makeJSONObject
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public JsonObject makeJSONObject(){
JsonObject json=new JsonObject();
try {
json.add(STOP_ID,jpti.indexOf(stop));
json.add(PICKUP,pickupType);
json.add(DROPOFF,dropoffType);
if(arrivalTime!=-1){
json.add(ARRIVAL_TIME,timeInt2String(arrivalTime));
}
if(departureTime!=-1){
json.add(DEPARTURE_TIME,timeInt2String(departureTime));
}
}catch(Exception e){
e.printStackTrace();
}
return json;
}
示例2: makeJSONObject
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public JsonObject makeJSONObject() {
JsonObject json = new JsonObject();
try {
json.add(OPERATION_NAME, operationName);
json.add(OPERATION_NO, operationNumber);
json.add(CALENDER_ID, calenderID);
JsonArray array = new JsonArray();
for (int i = 0; i < trip.size(); i++) {
JsonObject obj = new JsonObject();
obj.add(TRIP_ID, jpti.indexOf(trip.get(i)));
array.add(obj);
}
json.add(TRIP_LIST, array);
return json;
} catch (Exception e) {
e.printStackTrace();
}
return new JsonObject();
}
示例3: saveMeta
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public void saveMeta(String id, ObservationResult cur) {
JsonObject meta = new JsonObject();
meta.add("start", cur.getStart().getTime());
meta.add("end", cur.getEnd().getTime());
if (cur.getGain() != null) {
meta.add("gain", cur.getGain());
}
if (cur.getChannelA() != null) {
meta.add("channelA", cur.getChannelA());
}
if (cur.getChannelB() != null) {
meta.add("channelB", cur.getChannelB());
}
File dest = new File(basepath, id + File.separator + "data" + File.separator + cur.getId() + File.separator + "meta.json");
try (BufferedWriter w = new BufferedWriter(new FileWriter(dest))) {
w.append(meta.toString());
} catch (IOException e) {
LOG.error("unable to write meta", e);
}
}
示例4: makeJsonObject
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public JsonObject makeJsonObject(){
JsonObject json=new JsonObject();
try{
if(height>-1){
json.add(HEIGHT,height);
}
if(name!=null){
json.add(NAME,name);
}
if(bold){
json.add(BOLD,1);
}
if(itaric){
json.add(ITARIC,1);
}
}catch(Exception e){
e.printStackTrace();
}
return json;
}
示例5: doGet
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
@Override
public ModelAndView doGet(IHTTPSession session) {
ModelAndView result = new ModelAndView();
JsonObject entity = new JsonObject();
entity.add("domain", acmeClient.getSslDomain());
entity.add("enabled", acmeClient.isSSLEnabled());
entity.add("running", acmeClient.isRunning());
entity.add("agreeWithToC", acmeClient.isSSLEnabled() || acmeClient.isRunning());
JsonArray messages = new JsonArray();
for (String cur : acmeClient.getMessages()) {
JsonObject curObject = new JsonObject();
curObject.add("message", cur);
messages.add(curObject);
}
entity.add("log", messages);
result.setData(entity.toString());
return result;
}
示例6: toJson
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public JsonObject toJson() {
JsonObject obj = new JsonObject();
obj.add(ParamConstant.USER_ID, getEmail());
obj.add(ParamConstant.USER_NAME, getName());
obj.add(ParamConstant.USER_SUR_NAME, getSurName());
obj.add(ParamConstant.USER_COMPANY_ID, getCompanyId());
obj.add(ParamConstant.USER_PHONE, getPhone());
return obj;
}
示例7: doGet
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
@Override
public ModelAndView doGet(IHTTPSession session) {
ModelAndView result = new ModelAndView();
JsonObject entity = new JsonObject();
entity.add("configured", !auth.isFirstStart());
result.setData(entity.toString());
return result;
}
示例8: doLogin
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public static ModelAndView doLogin(Authenticator auth, String username, String password) {
String token = auth.authenticate(username, password);
ModelAndView result = new ModelAndView();
if (token == null) {
result.setData(new ValidationResult("Invalid login or password").toJson());
result.setStatus(Response.Status.UNAUTHORIZED);
} else {
JsonObject data = Json.object();
data.add("access_token", token);
data.add("token_type", "bearer");
data.add("expires_in", auth.getMaxAgeMillis() / 1000);
result.setData(data.toString());
}
return result;
}
示例9: makeJSONObject
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public JsonObject makeJSONObject(){
JsonObject json=new JsonObject();
try{
json.add(NAME,name);
}
catch(Exception e){
e.printStackTrace();
}
return json;
}
示例10: provisionFabric
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
private void provisionFabric(VlanId vlanId, ConnectPoint point, ConnectPoint fromPoint) {
long vlan = vlanId.toShort();
JsonObject node = new JsonObject();
node.add("vlan", vlan);
if (vlan == 201) {
node.add("iptv", true);
} else {
node.add("iptv", false);
}
JsonArray array = new JsonArray();
JsonObject cp1 = new JsonObject();
JsonObject cp2 = new JsonObject();
cp1.add("device", point.deviceId().toString());
cp1.add("port", point.port().toLong());
cp2.add("device", fromPoint.deviceId().toString());
cp2.add("port", fromPoint.port().toLong());
array.add(cp1);
array.add(cp2);
node.add("ports", array);
String baseUrl = "http://" + FABRIC_CONTROLLER_ADDRESS + ":"
+ Integer.toString(FABRIC_SERVER_PORT);
Client client = ClientBuilder.newClient();
WebTarget wt = client.target(baseUrl + FABRIC_BASE_URI);
Invocation.Builder builder = wt.request(JSON_UTF_8.toString());
builder.post(Entity.json(node.toString()));
}
示例11: makeJSONObject
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public JsonObject makeJSONObject(){
JsonObject json=new JsonObject();
try {
json.add(NAME, name);
if(subName!=null){
json.add(SUBNAME,subName);
}
if(type>0){
json.add(TYPE,type);
}
if(description!=null) {
json.add(DESCRIPTION, description);
}
if(lat!=null) {
json.add(LAT,lat);
}
if(lon!=null) {
json.add(LON,lon);
}
if(url!=null) {
json.add(URL,url);
}
if(wheelcharBoarding!=null) {
json.add(WHEELCHAIR,wheelcharBoarding);
}
json.add(STOP,makeStopsListJSON());
}catch(Exception e){
e.printStackTrace();
}
return json;
}
示例12: userLogIn
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public static Result userLogIn() {
UserModel model = userParser.parseUser(request());
JsonObject result = new JsonObject();
if (model != null && UserValidator.hasRequiredDataForLogin(model)) {
UserModel userModel = UserDao.getInstance().logIn(model.getEmail(), model.getPassword());
if (userModel != null) {
UserSessionModel userSessionModel = new UserSessionModel();
userSessionModel.setUserId(userModel.getEmail());
userSessionModel.setToken(Generator.createAccessToken());
userSessionModel.setRefreshToken(Generator.createRefreshToken());
userSessionModel.setStartDateTime(DateTimeUtil.getCurrentDate());
UserSessionDao.getInstance().save(userSessionModel);
LogUtil.printLogMessage("login_user", "user_session", userSessionModel.toString());
result.add(ResponseConstant.PARAMS_RESPONSE_CODE, ResponseConstant.RESPONSE_CODE_SUCCESS);
result.add(ResponseConstant.PARAMS_RESPONSE_MESSAGE, "login success");
result.add(ResponseConstant.PARAMS_RESPONSE_DATA, userSessionModel.toJson());
} else {
result.add(ResponseConstant.PARAMS_RESPONSE_CODE, ResponseConstant.RESPONSE_CODE_FAILED);
result.add(ResponseConstant.PARAMS_RESPONSE_MESSAGE, "Invalid email or password");
}
} else {
result.add(ResponseConstant.PARAMS_RESPONSE_CODE, ResponseConstant.RESPONSE_CODE_FAILED);
result.add(ResponseConstant.PARAMS_RESPONSE_MESSAGE, "Email and password required");
}
return ok(result.toString());
}
示例13: makeJSONObject
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public JsonObject makeJSONObject (){
JsonObject json=new JsonObject();
if(station==null){
return json;
}
try{
json.add(STATION_ID,jpti.indexOf(station));
if(km>-1){
json.add(KM,km);
}
if(numbering>-1){
json.add(NUMBERING,numbering);
}
if(bigStation){
json.add(TYPE,1);
}else{
json.add(TYPE,0);
}
if(viewStyle>-1){
json.add(VIEWSTYLE,String.format("%02d",viewStyle));
}
if(showStopNum>-1){
json.add(SHOW_STOPNUM,String.format("%02d",viewStyle));
}
if(border){
json.add(BORDER,1);
}else{
json.add(BORDER,0);
}
}catch(Exception e){
e.printStackTrace();
}
return json;
}
示例14: makeJSONObject
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public JsonObject makeJSONObject(){
try{
JsonObject json=new JsonObject();
json.add(DIRECT,direct);
if(name.length()>0){
json.add(NAME,name);
}
if(number.length()>0){
json.add(NUMBER,number);
}
if(count.length()>0){
json.add(COUNT,count);
}
if(text.length()>0){
json.add(TEXT,text);
}
if(calendar!=null){
json.add(CALENDER,jpti.indexOf(calendar));
}
JsonArray tripArray=new JsonArray();
for(Trip trip:tripList){
tripArray.add(jpti.indexOf(trip));
}
json.add(TRIP,tripArray);
return json;
}catch (Exception e){
e.printStackTrace();
}
return null;
}
示例15: toJson
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public String toJson() {
JsonObject result = Json.object();
if (!isEmpty()) {
JsonObject errors = Json.object();
if (general != null) {
errors.add("general", general);
}
for (Entry<String, String> cur : entrySet()) {
errors.add(cur.getKey(), cur.getValue());
}
result.add("errors", errors);
}
return result.toString();
}