This sample sets Argon.JsonReader.SupportMultipleContent
to true so that multiple JSON fragments can be read from a System.IO.Stream
or System.IO.TextReader
.
public class Role
{
public string Name { get; set; }
}
var json = "{ 'name': 'Admin' }{ 'name': 'Publisher' }";
var roles = new List<Role>();
var reader = new JsonTextReader(new StringReader(json))
{
SupportMultipleContent = true
};
while (true)
{
if (!reader.Read())
{
break;
}
var serializer = new JsonSerializer();
var role = serializer.Deserialize<Role>(reader);
roles.Add(role);
}
foreach (var role in roles)
{
Console.WriteLine(role.Name);
}
// Admin
// Publisher