private IEnumerable <Node> readNodes(JsonTextReader reader, RoadManager roads, JsonSerializer serializer, List <Node> nodes) { if (reader.Read()) { // start array if (reader.TokenType == JsonToken.StartArray) { do { if (reader.Read()) // inside node { if (reader.TokenType == JsonToken.StartObject) { var position = serializer.Deserialize <Vector3D>(reader); var node = roads.CreateNode(position); nodes.Add(node); yield return(node); } } } while (reader.TokenType != JsonToken.EndArray); } else { throw new FormatException("Expected array start"); } } }