D
D
Dmitry Fondomakin2019-04-11 12:38:59
C++ / C#
Dmitry Fondomakin, 2019-04-11 12:38:59

[C# + NetownSoft.Json] How to parse a file?

Good afternoon.
There is a test.json file with the following content:

[
  
  {
    "RecType": "Fact",
    "LMSZID": "4a382da4-6075-4500-8671-fc327c640275",
    "categoryID": "efd64fa2-cda9-45a7-90a1-bcfd600a03ff",
    "ONMSZCode": 2472.000001,
    "SNILS_recip": 11111111111,
    "FamilyName_recip": "Григорьева1",
    "Name_recip": "Нина",
    "Patronymic_recip": "Степановна",
    "Gender_recip": "Ж",
    "BirthDate_recip": "01.01.1935",
    "doctype_recip": 7,
    "doc_Series_recip": "Q-0.А",
    "doc_Number_recip": 0,
    "doc_IssueDate_recip": "06.08.2003",
    "doc_Issuer_recip": "Котельниковским о-м Люберецкого УВД МО",
    "SNILS_reason": "",
    "FamilyName_reason": "",
    "Name_reason": "",
    "Patronymic_reason": "",
    "Gender_reason": "",
    "BirthDate_reason": "",
    "doctype_reason": "",
    "doc_Series_reason": "",
    "doc_Number_reason": "",
    "doc_IssueDate_reason": "",
    "doc_Issuer_reason": "",
    "decision_date": "01.01.2018",
    "dateStart": "01.01.2018",
    "dateFinish": "01.06.2018",
    "usingSign": "Нет",
    "criteria": "",
    "FormCode": 1,
    "amount": "81,14",
    "measuryCode": 1,
    "monetization": "Нет",
    "content": "",
    "comment": "",
    "equivalentAmount": ""
  },
  {
    "RecType": "Fact",
    "LMSZID": "4a382da4-6075-4500-8671-fc327c640275",
    "categoryID": "efd64fa2-cda9-45a7-90a1-bcfd600a03ff",
    "ONMSZCode": 2472.000001,
    "SNILS_recip": 11111111111,
    "FamilyName_recip": "Григорьева2",
    "Name_recip": "Нина",
    "Patronymic_recip": "Степановна",
    "Gender_recip": "Ж",
    "BirthDate_recip": "01.01.1935",
    "doctype_recip": 7,
    "doc_Series_recip": "Q-0.А",
    "doc_Number_recip": 0,
    "doc_IssueDate_recip": "06.08.2003",
    "doc_Issuer_recip": "Котельниковским о-м Люберецкого УВД МО",
    "SNILS_reason": "",
    "FamilyName_reason": "",
    "Name_reason": "",
    "Patronymic_reason": "",
    "Gender_reason": "",
    "BirthDate_reason": "",
    "doctype_reason": "",
    "doc_Series_reason": "",
    "doc_Number_reason": "",
    "doc_IssueDate_reason": "",
    "doc_Issuer_reason": "",
    "decision_date": "01.01.2018",
    "dateStart": "01.01.2018",
    "dateFinish": "01.06.2018",
    "usingSign": "Нет",
    "criteria": "",
    "FormCode": 1,
    "amount": "81,14",
    "measuryCode": 1,
    "monetization": "Нет",
    "content": "",
    "comment": "",
    "equivalentAmount": ""
  },
  {
    "RecType": "Fact",
    "LMSZID": "4a382da4-6075-4500-8671-fc327c640275",
    "categoryID": "efd64fa2-cda9-45a7-90a1-bcfd600a03ff",
    "ONMSZCode": 2472.000001,
    "SNILS_recip": 11111111111,
    "FamilyName_recip": "Григорьева3",
    "Name_recip": "Нина",
    "Patronymic_recip": "Степановна",
    "Gender_recip": "Ж",
    "BirthDate_recip": "01.01.1935",
    "doctype_recip": 7,
    "doc_Series_recip": "Q-0.А",
    "doc_Number_recip": 0,
    "doc_IssueDate_recip": "06.08.2003",
    "doc_Issuer_recip": "Котельниковским о-м Люберецкого УВД МО",
    "SNILS_reason": "",
    "FamilyName_reason": "",
    "Name_reason": "",
    "Patronymic_reason": "",
    "Gender_reason": "",
    "BirthDate_reason": "",
    "doctype_reason": "",
    "doc_Series_reason": "",
    "doc_Number_reason": "",
    "doc_IssueDate_reason": "",
    "doc_Issuer_reason": "",
    "decision_date": "01.01.2018",
    "dateStart": "01.01.2018",
    "dateFinish": "01.06.2018",
    "usingSign": "Нет",
    "criteria": "",
    "FormCode": 1,
    "amount": "81,14",
    "measuryCode": 1,
    "monetization": "Нет",
    "content": "",
    "comment": "",
    "equivalentAmount": ""
  },
  {
    "RecType": "Fact",
    "LMSZID": "4a382da4-6075-4500-8671-fc327c640275",
    "categoryID": "efd64fa2-cda9-45a7-90a1-bcfd600a03ff",
    "ONMSZCode": 2472.000001,
    "SNILS_recip": 11111111111,
    "FamilyName_recip": "Григорьева4",
    "Name_recip": "Нина",
    "Patronymic_recip": "Степановна",
    "Gender_recip": "Ж",
    "BirthDate_recip": "01.01.1935",
    "doctype_recip": 7,
    "doc_Series_recip": "Q-0.А",
    "doc_Number_recip": 0,
    "doc_IssueDate_recip": "06.08.2003",
    "doc_Issuer_recip": "Котельниковским о-м Люберецкого УВД МО",
    "SNILS_reason": "",
    "FamilyName_reason": "",
    "Name_reason": "",
    "Patronymic_reason": "",
    "Gender_reason": "",
    "BirthDate_reason": "",
    "doctype_reason": "",
    "doc_Series_reason": "",
    "doc_Number_reason": "",
    "doc_IssueDate_reason": "",
    "doc_Issuer_reason": "",
    "decision_date": "01.01.2018",
    "dateStart": "01.01.2018",
    "dateFinish": "01.06.2018",
    "usingSign": "Нет",
    "criteria": "",
    "FormCode": 1,
    "amount": "81,14",
    "measuryCode": 1,
    "monetization": "Нет",
    "content": "",
    "comment": "",
    "equivalentAmount": ""
  }
]

At the moment, you need to get the data "ONMSZCode" and "FamilyName_recip". For parsing, I used the Oxoron instruction . Despite this, I get an error
Cannot deserialize the current JSON array (eg [1,2,3]) into type

I will be glad for any help.
UPD: There is a solution how to parse the data. But this decision is not related to the instruction that was specified by Oxoron According to his instructions, an error still occurs that the data cannot be parsed.
I would be very grateful if someone can correct exactly that example. At least I understand what I don't understand.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2019-04-11
@defond

https://dotnetfiddle.net/xX8RPa

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question