dongwen4487 2014-03-18 10:12
浏览 60

将JSON对象“按原样”存储到数据存储区中

I have to store a nested struct into datastore. As I'm running into the

datastore: flattening nested structs leads to a slice of slices: field

problem, I'd like to store the JSON object as is (as string?) to the datastore. Is this doable in Go?

  • 写回答

2条回答 默认 最新

  • doudi2520 2014-03-18 10:33
    关注

    You should be able to store the json.RawMessage. See the example in the package docs.

    RawMessage is a raw encoded JSON object. It implements Marshaler and Unmarshaler and can be used to delay JSON decoding or precompute a JSON encoding.

    It's a slice of byte, but you can easily convert it to a string if you wish.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度