V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
praynise
V2EX  ›  Go 编程语言

请问如何动态的将一个 slice 内的 json 串 unmarshal 到一个 slice 内的 struct 上呢

  •  
  •   praynise · 2019-03-08 17:41:13 +08:00 · 2036 次点击
    这是一个创建于 1877 天前的主题,其中的信息可能已经有所发展或是发生改变。
    小弟有一个需求,需要通过外部文件获取多个 json 字符串,放在一个[][]bytes 里面。然后将其 unmarshal 到另外一个[]struct 里面。由于 json 有很多种,需要 unmarshal 到不同的 struct 内。想咨询各位大神,有什么优雅的方式,实现一个方法,传入[][]bytes 和 interface{}(实际为各种[]struct),得到 unmarshal 后的[]struct 呢?
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5786 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 02:35 · PVG 10:35 · LAX 19:35 · JFK 22:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.