using System.Collections.Generic;
using System.Diagnostics;
public static int CountObject(string JsonFile)
int objectCounter = 0, currentDepth = 0;
for (int i = 0; i < JsonFile.Length; i++)
while (currentDepth >= 0)
static void Main(string[] args)
string _currentDir = Directory.GetCurrentDirectory();
string _jsonPath = Path.Combine(_currentDir, "file.json");
string jsonFile = File.ReadAllText(_jsonPath);
int len = CountObject(jsonFile);
Console.WriteLine("Il file json contiene " + len + " elementi\n");
var result = JsonConvert.DeserializeObject<list_result>(jsonFile);
Trace.WriteLine("result: " + result);
foreach (var entry in result.Cars)
Console.WriteLine(entry.Manufacturer + " " + entry.Model);
Console.WriteLine("new function");
Cars[] CarsArray = new Cars[len];
List<list_result> ListaMacchine = new List<list_result>();
foreach (Cars entry in result.Cars)
Console.WriteLine("entry:" + entry + "\n");
Console.WriteLine("CarsArray" + CarsArray[n].ToString());
public Cars[] Cars { get; set; }
public string manufacturer;
public string licensePlate;
public string Manufacturer
get { return Manufacturer; }
set { Manufacturer = value; }
public string LicensePlate
get { return licensePlate; }
set { licensePlate = value; }