Есть вот такой класс:
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;
namespace CounterPortal_2D.Classes
{
public enum SessionStatus
{
StartGame, EndGame, StateUpdate, WaitingForPlayers
}
public class SessionInstance
{
[JsonProperty("status")]
public SessionStatus status = SessionStatus.WaitingForPlayers;
[JsonProperty("players")]
public List<Player> players;
[JsonProperty("seed")]
public int seed;
public string Serialize()
{
return JsonConvert.SerializeObject(this);
}
public void Deserialize(string json)
{
SessionInstance nm = JsonConvert.DeserializeObject<SessionInstance>(json);
status = nm.status;
players = nm.players;
seed = nm.seed;
}
}
}
Вылетает почти всегда на:
SessionInstance nm = JsonConvert.DeserializeObject<SessionInstance>(json);
С ошибкой
Newtonsoft.Json.JsonReaderException: 'Additional text encountered after finished reading JSON content: {. Path '', line 1, position 890.'
Вот json, который пришел в deserialize:
"{\"status\":0,\"players\":[{\"id\":\"82110c34-1f31-46b5-ad59-3a99111c86fb\",\"status\":1,\"position\":\"100, 100\",\"rotation\":0.0,\"name\":null,\"score\":0,\"isAlive\":true,\"portals\":[{\"position\":\"-1000, -1000\"},{\"position\":\"-1000, -1000\"}],\"bullets\":[]},{\"id\":\"a009b57b-3bee-41c3-93cd-1d15edacf26e\",\"status\":1,\"position\":\"100, 100\",\"rotation\":0.0,\"name\":null,\"score\":0,\"isAlive\":true,\"portals\":[{\"position\":\"-1000, -1000\"},{\"position\":\"-1000, -1000\"}],\"bullets\":[]},{\"id\":\"20ff1b7d-19f7-4f95-a6b8-eca2703a0014\",\"status\":1,\"position\":\"100, 100\",\"rotation\":0.0,\"name\":null,\"score\":0,\"isAlive\":true,\"portals\":[{\"position\":\"-1000, -1000\"},{\"position\":\"-1000, -1000\"}],\"bullets\":[]},{\"id\":\"8e10de65-fcf5-45a4-93e1-9d87dabc23fc\",\"status\":1,\"position\":\"100, 100\",\"rotation\":0.0,\"name\":null,\"score\":0,\"isAlive\":true,\"portals\":[{\"position\":\"-1000, -1000\"},{\"position\":\"-1000, -1000\"}],\"bullets\":[]}],\"seed\":1295229578}{\"status\":2,\"players\":[{\"id\":\"82110c34-1f31-46b5-ad59-3a99111c86fb\",\"status\":1,\"position\":\"100, 100\",\"rotation\":0.0,\"name\":null,\"score\":0,\"isAlive\":true,\"portals\":[{\"position\":\"-1000, -1000\"},{\"position\":\"-1000, -1000\"}],\"bullets\":[]},{\"id\":\"a009b57b-3bee-41c3-93cd-1d15edacf26e\",\"status\":1,\"position\":\"100, 100\",\"rotation\":0.0,\"name\":null,\"score\":0,\"isAlive\":true,\"portals\":[{\"position\":\"-1000, -1000\"},{\"position\":\"-1000, -1000\"}],\"bullets\":[]},{\"id\":\"20ff1b7d-19f7-4f95-a6b8-eca2703a0014\",\"status\":1,\"position\":\"100, 100\",\"rotation\":0.0,\"name\":null,\"score\":0,\"isAlive\":true,\"portals\":[{\"position\":\"-1000, -1000\"},{\"position\":\"-1000, -1000\"}],\"bullets\":[]},{\"id\":\"8e10de65-fcf5-45a4-93e1-9d87dabc23fc\",\"status\":1,\"position\":\"100, 100\",\"rotation\":0.0,\"name\":null,\"score\":0,\"isAlive\":true,\"portals\":[{\"position\":\"-1000, -1000\"},{\"position\":\"-1000, -1000\"}],\"bullets\":[]}],\"seed\":1295229578}"
Я вообще не понимаю где ошибка, вижуалка указывает на максимально не подозрительный ключ