Во-первых, ваш json файл не является допустимым json, вместо использования { { ... } }
, вы должны либо использовать { ... }
или [{ ... }]
для массива объекта
Во-вторых, ваше свойство поле должно быть заключено в кавычки, такие как "id":5
Здесь вы действительны json
{
"id": "13",
"id_user": "2",
"login": "ajmal@freedomofdev.com",
"price_category": "Senior",
"email": "ajmal@freedomofdev.com",
"id_tracker": "16",
"id_owner": "2",
"id_task": "8",
"id_tag": null,
"id_customer": "2",
"id_customer_tracker": "9",
"iscompany": "1",
"color": "048dc4",
"name": "SRA",
"path": "Freedom of dev > Solution reporting > SRA",
"path_relative_to_customer": "Solution reporting > SRA",
"type": "2",
"date_start": "2020-03-06 08:00:00",
"date_end": "2020-03-06 12:00:00",
"hstart": "08:00",
"hend": "12:00",
"date_start_formatted": "06/03/2020",
"date_end_formatted": "06/03/2020",
"ts_start": "1583478000",
"ts_end": "1583492400",
"tz_offset_start": "3600",
"tz_offset_end": "3600",
"locked": false,
"id_invoice": null,
"invoice_ref": null,
"partial": false,
"comment": "[US Technique] mise en place du projet",
"quantity_not_rounded": 4,
"quantity": 4,
"quantity_set": false,
"default_quantity": 4,
"seconds": 14400,
"duration": "4h00",
"hours": 4,
"hascomment": null,
"eventuri": null,
"eventuid": null,
"copy_quantity_from": null,
"location": null,
"item_count": 0,
"invoice_status": "none",
"planning_status": "done",
"future": false,
"time_billing": "normal",
"invoiceable": "1",
"budget_source": null,
"budget_invoice": null,
"budget_periodicity": null,
"unitary_price": "7.000000",
"unitary_cost": "0.000000",
"id_price_level": null,
"path_relative_to_customer_item_time": null,
"label": "Solution reporting > SRA",
"description": "",
"id_unit": "1000",
"unit": "h",
"unit_hours": "1.00",
"base_unitary_price": "7.00000000",
"id_vat_type": null,
"ignored": "0",
"apply_zones": "0",
"price": 28,
"priceByZone": {
"normal": 7,
"overtime": 7,
"weekend": 7
},
"secondsByZone": {
"normal": 14400,
"overtime": 0,
"weekend": 0,
"total": 14400,
"main": "normal"
}
}
Ваш код для помещения его в ваш объект прост как
var rootObjectTT = JsonConvert.DeserializeObject<RootObjectTT>(jsonexample);
Console.WriteLine(rootObjectTT.priceByZone.normal);
Console.WriteLine(rootObjectTT.secondsByZone.normal);
Console.WriteLine(rootObjectTT.price);
Надеюсь, что это поможет