Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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?
Posted
Updated 7-Mar-18 1:36am
Comments
#realJSOP 7-Mar-18 7:42am    
Post a portion of the json file so we can see what you're talking about.
Richard MacCutchan 7-Mar-18 8:28am    
Read it line by line and deserialize each line.

1 solution

>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!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900