I have a Dictionary<string, object> advertiserResponse
that looks like this...
"AdvertiserLookup": {
"Agency": {
"AgencyAlpha": "ABC",
"Media": [
{
"Code": "123",
"Name": "XYZ",
"Advertisers": {
"Advertiser": [
{
"Code": "JKL",
"Name": "EFG",
"BusinessKey": "HIJ"
},
{
"Code": "KLM",
"Name": "NOP",
"BusinessKey": "QRS"
},
{
This is the line I'm using to try to write to a text file:
File.WriteAllLines("test.txt", advertiserResponse.Select(x => "[" + x.Key + " " + x.Value + "]").ToArray());
I'm expecting the Json (not necessary in pretty print) with all keys and text below AdvertiserLookup
.
What I get in test.txt
:
[AdvertiserLookup System.Collections.Generic.Dictionary``2[System.String,System.Object]]
How do I write the entire thing to text?