A
A
Anton2018-01-28 16:31:59
C++ / C#
Anton, 2018-01-28 16:31:59

Deserializing json fields into an array?

Hello. I have a set of dynamic json fields

{
"photo_75": " ... ",
"photo_130": " ... ",
"photo_604": " ... ",
"photo_807": " ... ",
"photo_1280": " .. ."
}

I need to place all fields with the photo_ prefix in the dictionary, or put the values ​​​​of the largest photo_ NUM into a separate field

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2018-01-28
@kttotto

var model = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
var photos = model.Where(x => x.Key.Contains("photo"));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question