zackmark15
zackmark15

Reputation: 727

Combine JSON string values from different Object

I want to combine this two string values I have this LINQ code but I can't figure out how merge them I can only get the list by Object

List<string> All = new List<string>();

var _synopsis = ((IEnumerable<dynamic>)json.data.series.product
                                      .Where(x => x.synopsis !=null)
                                      .Select(x => x.synopsis).ToList());

var _number = ((IEnumerable<dynamic>)json.data.series.product
                                      .Where(x => x.number != null)
                                      .Select(x => x.number).ToList());

foreach (var a in _synopsis)
{
    All.Add(a);
}

foreach (var x in _number)
{
    All.Add(x);
}

I want the result become like this:

for example: 
_synopsis(TITLE) + _number(EPISODE)
result: TITLE + EPISODE

Here is the JSON structure: enter image description here

Upvotes: 0

Views: 83

Answers (1)

Guru Stron
Guru Stron

Reputation: 141845

I'm assuming you are looking for something like this:

List<string> All = ((IEnumerable<dynamic>)json.data.series.product
    .Where(x => x.synopsis != null && x.number != null)
    .Select(x => x.synopsis + " + " + x.number)
    .ToList());

Upvotes: 1

Related Questions