如何读取多个数据json文件? [英] How to read multiple data json file ?
本文介绍了如何读取多个数据json文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友,
我有一个包含多条JSON消息的文本文件。除了新行之外没有分隔符。我有一个方法,它将采用JSON字符串并将其反序列化为某种对象类型。
请告诉我
我尝试了什么:
如何读取文本文件并遍历每个Json字符串以便反序列化?
解决方案
>除了新行之外没有分隔符。
LOL,但新行是分隔符够了!
只需拆分你的字符串就好了
string [] arJson = theText.Split(
new [] {Environment.NewLine},
StringSplitOptions.None
);
并遍历arJson!
Hello friend,
I have a text file which contains multiple JSON messages. There is no separator except new line. I have a method which will take JSON string and deserialize it to some object type.
Please tell me
What I have tried:
How can I read text file and iterate through each Json string so that it can be deserialized?
解决方案
>There is no separator except new line.
LOL, but new line is a separator enough!
Just split your string like
string[] arJson = theText.Split( new[] { Environment.NewLine }, StringSplitOptions.None );
and iterate through arJson!
这篇关于如何读取多个数据json文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文