如何格式化List< List< int>>作为JSON文件中的表格? [英] How to format List<List<int>> as a table in JSON file?
问题描述
我使用Newtonsoft.Json库对.NET对象进行序列化和反序列化.
我要序列化的东西之一是表(表示为List<List<int>>
).
我需要的是像表格一样在序列化文件中格式化它们,而不是像现在那样格式化一堆列.有什么办法可以做到这一点?
I use Newtonsoft.Json library for serializing and deserializing .NET objects.
One of the things I am serializing are tables (represented as List<List<int>>
).
What I need is to format them in the serialized file like a table, not like a bunch of columns as they are formatted now. Is there any way to achieve this?
现在,我在json文件中具有以下格式:
Now, I have the following formatting in the json-file:
"Table": [
[
1024,
1024,
1024,
1024
],
[
1024,
1024,
1024,
1024
],
[
1024,
1024,
1024,
1024
]
]
我想实现的是这样:
"Table": [
[1024, 1024, 1024, 1024],
[1024, 1024, 1024, 1024],
[1024, 1024, 1024, 1024]
]
推荐答案
我想要一种更紧凑的格式,关于这个的问题下面已经有一些评论.
如果要提高可读性,可以使用List<Map<string /*columndName*/, int>>
I you want a more compact format there are already some comments below your question about that.
If you want more readability you could use a list of mapping of columnName to columnValue by List<Map<string /*columndName*/, int>>
这篇关于如何格式化List< List< int>>作为JSON文件中的表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!