如何使用 Spring Data Couchbase 在 Java 对象中映射 JSON 数组

问题描述

我有一个沙发底桶,里面装满了这样的 JSON 数组

["a","b","c"]

我正在使用 Spring boot 的 CouchbaseTemplate 从这个存储桶中获取文档,我想将它们映射到 Java 的列表。

目前我正在这样做:

@RestController
public class Controller {

  private final CouchbaseTemplate template;

  public Controller(CouchbaseTemplate template) {
    this.template = template;
  }

  @GetMapping("/{id}")
  public Mono<List<String>> getStuff(@PathVariable("id") String id) {
    return template.reactive()
        .findById(List.class)
        .one(id)
        .map(list -> ((List<String>) list));
  }
}

看起来 Spring 数据层绝对想要一个 CouchbaseDocument 作为源,但 JacksonTranslationService 返回一个 CouchbaseList(在我的情况下是完美的)

有没有办法在没有任何映射的情况下检索原始文档?或者有没有更好的方法来做到这一点?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)