azure - documentdb 从 null 值返回空对象

标签 azure azure-cosmosdb

我正在针对 documentdb 集合调用类似于以下代码的内容:

List<DocumentCollection> collectionList = documentClient
                .queryCollections(
                        getTodoDatabase().getSelfLink(),
                        "SELECT * FROM root r WHERE r.id='" + COLLECTION_ID
                                + "'", null).getQueryIterable().toList();

我返回的 json 在某些字段上有 null,这很好,但是当我返回 collectionList 时,null 会转换为空 JSON 对象;例如:

"`content`" : `null` is converted to "`content`" : `{}`

有谁知道有没有办法解决这个问题?

最佳答案

添加 WHERE 子句,使用类型检查函数指定您期望的类型

IS_ARRAY、IS_BOOL、IS_NULL、IS_NUMBER、IS_OBJECT、IS_STRING、IS_DEFINED 和 IS_PRIMITIVE

关于azure - documentdb 从 null 值返回空对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35665198/

相关文章:

azure - 错误: The order by query does not have a corresponding composite index that it can be served from

c# - C# 中 Azure Webjob 中的 GraceFul ShutDown

添加 VNET 集成时,由于 ManagedEnvironmentResourceGroupDisallowedByPolicy 错误,Azure 容器应用环境创建失败

azure - Azure 函数中的 Cosmos DB 408 响应

azure - SDG 是否适用于子网的服务端点

azure - F# Azure Function 的 Cosmos DB 绑定(bind)无法绑定(bind)

c# - 如何创建没有持续时间或有效期较长的 Windows Azure 媒体服务访问策略?

azure - 如何传入 CosmosDBTrigger 的存储帐户连接字符串?

spring-boot - 如何在 CosmosDB 中处理事务 - "All or nothing"概念

linq - 在 DocumentDb 中使用 ThenBy 显示错误