How to format List<List<int>> as a table in JSON file?

人走茶凉 提交于 2019-12-11 07:54:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!