F-ES Sitecore
string noteText = "{locations : [{name: \"loc1\"}, {name:\"loc2\"}]}";
// you're converting to dynamic so use that in the angled brackets, not string
dynamic model = JsonConvert.DeserializeObject<dynamic>(noteText);
var n = model.locations[0].name;
Если он все еще не работает, то проверьте, соответствует ли ваш код форме ваших объектов json.
muharrem altun
Я попробовал вам soulution, но получил ошибку в этой строке: var n=model.locations[0].name;
Сообщение об ошибке : строка 'не содержит определения' location '.
Мой json начинается так:
{ "locations": [ { "name": "accounts/103890250566243670362/locations/17566485131419324180", "storeCode": "006841020I01", "locationName": "İstikbal - ATAK TICARET", "primaryPhone": "(0312) 814 10 22", "primaryCategory": { "displayName": "Mobilya mağazası", "categoryId": "gcid:furniture_store" }, "websiteUrl": "http://www.istikbal.com.tr/", "regularHours": { "periods": [ { "openDay": "SUNDAY", "openTime": "09:00", "closeDay": "SUNDAY", "closeTime": "21:00" }, { "openDay": "MONDAY", "openTime": "09:00", "closeDay": "MONDAY", "closeTime": "21:00" }, { "openDay": "TUESDAY", "openTime": "09:00", "closeDay": "TUESDAY", "closeTime": "21:00" }, { "openDay": "WEDNESDAY", "openTime": "09:00", "closeDay": "WEDNESDAY", "closeTime": "21:00" }, { "openDay": "THURSDAY", "openTime": "09:00", "closeDay": "THURSDAY", "closeTime": "21:00" }, { "openDay": "FRIDAY", "openTime": "09:00", "closeDay": "FRIDAY", "closeTime": "21:00" }, { "openDay": "SATURDAY", "openTime": "09:00", "closeDay": "SATURDAY", "closeTime": "21:00" } ] }, "locationKey": { "placeId": "ChIJux7UUUVwgkAR4AuSDLY30hY", .....