【问题标题】:Save class field in particular order in Spring couchbase在 Spring couchbase 中以特定顺序保存类字段
【发布时间】:2017-06-19 12:08:40
【问题描述】:

我在 Spring Boot 应用程序中使用 couchbase 作为 Spring-data, 我正在保存一个班级,比如说 Employee 其中包含字段 empId、empName、empDesc 等。 我想以特定顺序将此对象保存在沙发库中。 假设我想按顺序将此 json 保存在 couchbase 中

{
  "empName": "hello",
  "empDesc": "helloDesc",
  "empId": "hello11"
}

我怎样才能做到这一点? 任何帮助表示赞赏。

【问题讨论】:

标签: spring spring-boot spring-data couchbase


【解决方案1】:

我认为你没有抓住重点。键的顺序在 JSON 对象中无关紧要,无论是否在 Couchbase 中。

对象是一组无序的名称/值对。

参见http://json.org/

如果顺序对您很重要,您应该使用 JSON 数组。 不要以不正当的方式使用 API 或框架,它通常会以错误的方式结束。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-28
    • 2019-03-21
    • 1970-01-01
    • 2021-08-23
    • 2019-05-11
    • 2018-08-03
    • 1970-01-01
    相关资源
    最近更新 更多