问题
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?
Now, I have the following formatting in the json-file:
"Table": [
[
1024,
1024,
1024,
1024
],
[
1024,
1024,
1024,
1024
],
[
1024,
1024,
1024,
1024
]
]
What I want to achieve is this:
"Table": [
[1024, 1024, 1024, 1024],
[1024, 1024, 1024, 1024],
[1024, 1024, 1024, 1024]
]
回答1:
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>>
来源:https://stackoverflow.com/questions/9357582/how-to-format-listlistint-as-a-table-in-json-file