admin管理员组文章数量:1292115
I have a map where the keys of outer keys are fixed. But the keys of inner map are not fixed and it can be anything.
Example: [ "fixed_key1": "Hi, Let me know further details", "fixed_key2" : [ "unknow_key1" : "value1", "unknown_key2" : "value2", "unknown_key3" : "value3" ], "fixed_key3" : "End of json" ]
Now, when I marshal this to json in go
the order of keys is not reserved (order of outer and inner json) both are not preserved.
example: { "fixed_key3":"End of json", "fixed_key2":{ "unknow_key2":"value2", "unknown_key3":"value3", "unknown_key1":"value1" }, "fixed_key1":"Hi, Let me know further details" }
If you see after marshal the order of both outer and inner json is not preserved.
I want to preserve the order. **Correct order I want : ** { "fixed_key1":"Hi, Let me know further details", "fixed_key2":{ "unknow_key1":"value1", "unknown_key2":"value2", "unknown_key3":"value3" }, "fixed_key3":"End of json" }
How to achive it in go lang Go version: 1.19.4
本文标签: Preserve json keys order while marshal in go langStack Overflow
版权声明:本文标题:Preserve json keys order while marshal in go lang - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741548119a2384716.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论