Insert a dictionary into another dictionary


#1

Hiii !!

I am working with dictionaries collections I tried put into one dictionary other dictionary as value parameter but It is shown an error that mentions “Expression does nor produce a value”.

where is the error?

This is the string in the value parameter.

SubDicc.Add(“Value”+SubDicc.Count.ToString ,convert.ToDouble( row.Item(4).tostring))


#2

Have you got any solution , how to use dictionary inside dictionary (i have got similar usecase to implement) ?


#3

@RJ_Kadari, Above error is because Cesar Cu is trying to add a value to another dictionary instead of producing a value. i.e Adding a dictionary happens where a value has to be entered.
May I know your complete requirement ?

Regards,
Dominic :slight_smile:


#4

actually i need to add into dictionary in below format , could you please check ?

{
“id”: “123124”,
“MetaID”: “235346”,
“logID”: “23694”,
“ForcedFIelds”: [{
“label”: “FirstName”,
“Value”: “abc”,
“Mappings”: {
“name”: “FirstName”,
“datatype”: “String”,
“elementType”: “Input”
}
},
{
“label”: “LastName”,
“Value”: “efg”,
“Mappings”: {
“name”: “LastName”,
“datatype”: “String”,
“elementType”: “Input”
}
}
],
“FIelds”: [{
“label”: “City”,
“Value”: “xyz”,
“Mappings”: {
“name”: “City”,
“datatype”: “String”,
“elementType”: “Select”
}
},
{
“label”: “StateID”,
“Value”: “HYD”,
“Mappings”: {
“name”: “StateID”,
“datatype”: “String”,
“elementType”: “Select”
}
}
]

}


#5

@RJ_Kadari, Is this entire in a string ? Do you want to add this in a dictionary as a value ?

Can you provide some info on this in detail ??

Regards,
Dominic :slight_smile:


#6

Hi Dominic,
Thanks, Would like to add below format using dictionary?
{
“label”: “FirstName”,
“Value”: “abc”,
“Mappings”: {
“name”: “FirstName”,
“datatype”: “String”,
“elementType”: “Input”
}
}

are these details enough ?


#7

@RJ_Kadari, Not sure about my suggestion. This can be done by JSON not by dictionary I think.

Regards,
Dominic :slight_smile:


#8

problem solved : we have trieated dictionary inner dictionary as string