I
I
iamdivine2021-08-20 08:11:50
JSON
iamdivine, 2021-08-20 08:11:50

How to match price from one JSON to another?

Good afternoon! I have JSON like this

{
  "name": "Дмитрий Иванов",
  "attr": "Ноут. HP-1111(владелец)\nНоут MSI модель666(владелец)"
}

I serialized it, everything is ok. I created a class and displayed, for example, data about it, but there is a second JSON:
{
    "Ноут. HP-1111(владелец)": 18000,
    "Ноут MSI модель666(владелец)": 13600,
     "Ноут MSI модель667(владелец)": 136001
}


Created a class like this

public class Noteboks
    {
        [JsonProperty("Ноут. HP-1111(владелец)")]
        public string HP1{ get; set; }
        [JsonProperty("Ноут MSI модель666(владелец)")]
        public string MSI1{ get; set; }
    }

The attr key can have a different combination of data from another JSON, 1,2 or even 10 notes. I need to sort through all the data in attr for matches and add up the price of laptops. Help)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pankov, 2021-08-20
@iamdivine

 And what, exactly, is the problem? Divide the line with the technique into paragraphs and look for the resulting lines in your price list. What is difficult for you? Split line at paragraph character? Iterate over the resulting elements? Look up each in a dictionary? Sum the found prices?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question