当前位置: 首页>>代码示例>>Java>>正文


Java Document.toJson方法代码示例

本文整理汇总了Java中org.bson.Document.toJson方法的典型用法代码示例。如果您正苦于以下问题:Java Document.toJson方法的具体用法?Java Document.toJson怎么用?Java Document.toJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bson.Document的用法示例。


在下文中一共展示了Document.toJson方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSession

import org.bson.Document; //导入方法依赖的package包/类
@Override
protected  String createSession(String sessionId, String customerId, Date creation, Date expiration) {
	Document sessionDoc = new Document("_id", sessionId)
       .append("customerid", customerId)
       .append("lastAccessedTime", creation)
       .append("timeoutTime", expiration);
	
	customerSession.insertOne(sessionDoc);
	
	return sessionDoc.toJson();
	
}
 
开发者ID:ibmruntimes,项目名称:acmeair-modular,代码行数:13,代码来源:AuthServiceImpl.java

示例2: createAddress

import org.bson.Document; //导入方法依赖的package包/类
@Override 
public String createAddress (String streetAddress1, String streetAddress2,
		String city, String stateProvince, String country, String postalCode){
	Document addressDoc = new Document("streetAddress1", streetAddress1)
	   .append("city", city)
	   .append("stateProvince", stateProvince)
	   .append("country", country)
	   .append("postalCode", postalCode);
	if (streetAddress2 != null){
		addressDoc.append("streetAddress2", streetAddress2);
	}
	return addressDoc.toJson();
}
 
开发者ID:ibmruntimes,项目名称:acmeair-modular,代码行数:14,代码来源:CustomerServiceImpl.java

示例3: getCustomerByUsername

import org.bson.Document; //导入方法依赖的package包/类
@Override
public String getCustomerByUsername(String username) {
	Document customerDoc = customer.find(eq("_id", username)).first();
	if (customerDoc != null) {
		customerDoc.remove("password");
		customerDoc.append("password", null);
	}
	return customerDoc.toJson();
}
 
开发者ID:ibmruntimes,项目名称:acmeair-modular,代码行数:10,代码来源:CustomerServiceImpl.java

示例4: emailConfirm

import org.bson.Document; //导入方法依赖的package包/类
/**
 * Confirm a newly registered email in this context
 *
 * @param token   confirmation token emailed to new user
 * @param tokenId confirmation tokenId emailed to new user
 * @return A task containing whether or not the email was confirmed successfully
 */
public Task<Boolean> emailConfirm(@NonNull final String token, @NonNull final String tokenId) {
    final TaskCompletionSource<Boolean> future = new TaskCompletionSource<>();

    final String url = String.format(
            "%s/%s",
            getResourcePath(routes.AUTH),
            routes.USERPASS_CONFIRM
    );

    final Document params = new Document();

    params.put("token", token);
    params.put("tokenId", tokenId);

    final JsonStringRequest request = new JsonStringRequest(
            Request.Method.POST,
            url,
            params.toJson(),
            new Response.Listener<String>() {
                @Override
                public void onResponse(final String response) {
                    future.setResult(response != null);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(final VolleyError error) {
                    Log.e(TAG, "Error while confirming email", error);
                    future.setException(parseRequestError(error));
                }
            }
    );

    request.setTag(this);
    _queue.add(request);

    return future.getTask();
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:46,代码来源:StitchClient.java

示例5: getUser

import org.bson.Document; //导入方法依赖的package包/类
public String getUser(String id) {
    FindIterable<Document> jsonUsers
            = userCollection
                .find(eq("_id", new ObjectId(id)));

    Iterator<Document> iterator = jsonUsers.iterator();

    Document user = iterator.next();

    return user.toJson();
}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-2-spraguesanborn,代码行数:12,代码来源:UserController.java

示例6: getFlower

import org.bson.Document; //导入方法依赖的package包/类
public String getFlower(String id) {
    FindIterable<Document> jsonFlowers
            = flowerCollection
            .find(eq("_id", new ObjectId(id)));

    Iterator<Document> iterator = jsonFlowers.iterator();

    Document flower = iterator.next();

    return flower.toJson();
}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-2-spraguesanborn,代码行数:12,代码来源:FlowerController.java

示例7: listBeds

import org.bson.Document; //导入方法依赖的package包/类
public String listBeds() {
    Document output = new Document();
    DistinctIterable<String> beds
            = flowerCollection
            .distinct("gardenLocation",String.class);

    for (String bed: beds){
        output.append(bed,bed);
    }

    return output.toJson();
}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-2-spraguesanborn,代码行数:13,代码来源:FlowerController.java

示例8: resetPassword

import org.bson.Document; //导入方法依赖的package包/类
/**
 * Reset a given user's password
 *
 * @param token token associated with this user
 * @param tokenId id of the token associated with this user
 * @return A task containing whether or not the reset was successful
 */
public Task<Boolean> resetPassword(@NonNull final String token,
                                   @NonNull final String tokenId,
                                   @NonNull final String password) {
    final TaskCompletionSource<Boolean> future = new TaskCompletionSource<>();

    final String url = String.format(
            "%s/%s",
            getResourcePath(routes.AUTH),
            routes.USERPASS_RESET
    );

    final Document params = new Document();

    params.put(RegistrationFields.TOKEN, token);
    params.put(RegistrationFields.TOKEN_ID, tokenId);
    params.put(RegistrationFields.PASSWORD, password);

    final JsonStringRequest request = new JsonStringRequest(
            Request.Method.POST,
            url,
            params.toJson(),
            new Response.Listener<String>() {
                @Override
                public void onResponse(final String response) {
                    future.setResult(response != null);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(final VolleyError error) {
                    Log.e(TAG, "Error while reseting password", error);
                    future.setException(parseRequestError(error));
                }
            }
    );

    request.setTag(this);
    _queue.add(request);

    return future.getTask();
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:49,代码来源:StitchClient.java

示例9: documentToObject

import org.bson.Document; //导入方法依赖的package包/类
/**
 * mongodb转对象格式
 * 
 * @param document
 * @param clazz
 * @return
 */
public static <T> T documentToObject(Document document, Class<T> clazz) {
	Gson gson = new Gson();
	String objStr = document.toJson();
	T obj = gson.fromJson(objStr, clazz);
	return obj;
}
 
开发者ID:dianbaer,项目名称:grain,代码行数:14,代码来源:MongodbManager.java


注:本文中的org.bson.Document.toJson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。