I have Dictionary
like this below.
The key is names like cups, pens, tape, glasses, and rocks. The values will be classes that contain things such as amount, types, images, etc.
The value is from the JSON file and contains all the values with keys associated with values.
Is it possible to have duplicate keys with different values?
For example, I want to add new values to each key and have different values with duplicated keys.
I want to get the output like
name: cup
amount: 3
colors: red
location: home //this will be the new value
name: cup
amount: 3
colors: yellow //duplicated key cup with different value
location: home //this will be the new value
New values would be location:
location: home
Is it possible?
Dictionary<string, Things> myDictionary;
public class Things{
public string name;
public int amount;
public string colors;
//...
}
foreach(Things item in thingsList.jsonfile)
{
//go through each item and add to item key as name (cup, pens, etc) and other for values (amount, colors)
}
JSON
"Things": [
{
"name": "cups",
"amount": 5,
"colors": "red",
//...
},
{
"name": "pens",
"amount": 3,
"colors": "blue",
},
{
"name": "cup",
"amount": 3,
"colors": "yellow",
}
],
I looked at this and possible to use Lookup
but not sure how to use it because I am not able to find examples using Lookup
with Dictionary
.