Я пытаюсь десериализовать эту строку, чтобы поместить данные в таблицу (я использую Blazor), мне нужны только ItemIds ItemSections (на самом деле мне нужно поместить их все в таблицу), остальная часть от него можно избавиться. Дело в том, что я пытаюсь заставить это работать, но немного застрял.
Это строка:
{
"id": 6,
"description": "Accounting",
"position": 0,
"enabled": true,
"itemSections": [
{
"itemId": 7,
"sectionId": 6,
"item": {
"id": 7,
"type": 2,
"description": "ctb_1",
"notes": "",
"shortDescription": "ctb_1",
"code": "",
"enabled": true,
"guid": null,
"itemSections": [
null
],
"layouts": [],
"scopes": [],
"users": [],
"bookmarks": [],
"tenantId": null
},
"section": null,
"position": 0
},
{
"itemId": 8,
"sectionId": 6,
"item": {
"id": 8,
"type": 2,
"description": "ctb_2",
"notes": "",
"shortDescription": "ctb_2",
"code": "string",
"enabled": true,
"guid": null,
"itemSections": [
null
],
"layouts": [],
"scopes": [],
"users": [],
"bookmarks": [],
"tenantId": null
},
"section": null,
"position": 0
},
{
"itemId": 9,
"sectionId": 6,
"item": {
"id": 9,
"type": 2,
"description": "TIMELINE ADEMPIMENTI",
"notes": "s",
"shortDescription": "TIMELINE ADEMPIMENTI",
"code": "string",
"enabled": true,
"guid": null,
"itemSections": [
null
],
"layouts": [],
"scopes": [],
"users": [],
"bookmarks": [],
"tenantId": null
},
"section": null,
"position": 0
}
],
"users": [
{
"id": 1,
"name": "Administrator",
"email": null,
"role": 1,
"login": "string",
"password": "string",
"enabled": true,
"canImpersonate": true,
"theme": null,
"layouts": [],
"userFilters": [],
"items": [],
"scopes": [],
"sections": [
null
],
"bookmarks": [],
"tenantId": null
}
]
}
Это десериализация, на всякий случай (элементы — это список):
items = JsonSerializer.Deserialize(jsonDocument.RootElement, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
});
А также таблица, которую я пытаюсь поместить, в которую я пытаюсь поместить все данные, возможно, здесь тоже что-то не так:
@* headers *@
Id
Description
Position
Enabled
Item Sections
Users
Data
@foreach (var item in items)
{
@* dati *@
@item.Id
@item.Description
@item.Position
@item.Enabled
@string.Join(", ", item.ItemSections)
@string.Join(", ", item.Users)
Подробнее здесь: https://stackoverflow.com/questions/785 ... his-string
Как я могу десериализовать эту строку? ⇐ C#
Место общения программистов C#
1716969449
Anonymous
Я пытаюсь десериализовать эту строку, чтобы поместить данные в таблицу (я использую Blazor), мне нужны только ItemIds ItemSections (на самом деле мне нужно поместить их все в таблицу), остальная часть от него можно избавиться. Дело в том, что я пытаюсь заставить это работать, но немного застрял.
Это строка:
{
"id": 6,
"description": "Accounting",
"position": 0,
"enabled": true,
"itemSections": [
{
"itemId": 7,
"sectionId": 6,
"item": {
"id": 7,
"type": 2,
"description": "ctb_1",
"notes": "",
"shortDescription": "ctb_1",
"code": "",
"enabled": true,
"guid": null,
"itemSections": [
null
],
"layouts": [],
"scopes": [],
"users": [],
"bookmarks": [],
"tenantId": null
},
"section": null,
"position": 0
},
{
"itemId": 8,
"sectionId": 6,
"item": {
"id": 8,
"type": 2,
"description": "ctb_2",
"notes": "",
"shortDescription": "ctb_2",
"code": "string",
"enabled": true,
"guid": null,
"itemSections": [
null
],
"layouts": [],
"scopes": [],
"users": [],
"bookmarks": [],
"tenantId": null
},
"section": null,
"position": 0
},
{
"itemId": 9,
"sectionId": 6,
"item": {
"id": 9,
"type": 2,
"description": "TIMELINE ADEMPIMENTI",
"notes": "s",
"shortDescription": "TIMELINE ADEMPIMENTI",
"code": "string",
"enabled": true,
"guid": null,
"itemSections": [
null
],
"layouts": [],
"scopes": [],
"users": [],
"bookmarks": [],
"tenantId": null
},
"section": null,
"position": 0
}
],
"users": [
{
"id": 1,
"name": "Administrator",
"email": null,
"role": 1,
"login": "string",
"password": "string",
"enabled": true,
"canImpersonate": true,
"theme": null,
"layouts": [],
"userFilters": [],
"items": [],
"scopes": [],
"sections": [
null
],
"bookmarks": [],
"tenantId": null
}
]
}
Это десериализация, на всякий случай (элементы — это список):
items = JsonSerializer.Deserialize(jsonDocument.RootElement, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
});
А также таблица, которую я пытаюсь поместить, в которую я пытаюсь поместить все данные, возможно, здесь тоже что-то не так:
@* headers *@
Id
Description
Position
Enabled
Item Sections
Users
Data
@foreach (var item in items)
{
@* dati *@
@item.Id
@item.Description
@item.Position
@item.Enabled
@string.Join(", ", item.ItemSections)
@string.Join(", ", item.Users)
Подробнее здесь: [url]https://stackoverflow.com/questions/78548080/how-can-i-deserialize-this-string[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия