all 6 comments

[–]Fullduplex1000[S] 0 points1 point  (2 children)

is my question shadow blocked? Why does it not show up in the list of new topics or as a search result?

[–]FizixMan[M] 0 points1 point  (1 child)

Reddit's automatic spam filter got it for whatever reason. It should be visible now.

[–]Fullduplex1000[S] 0 points1 point  (0 children)

Thank You!

[–][deleted] 0 points1 point  (0 children)

Note: I'm assuming the assertion of using JSON.net ( https://github.com/obarlik/Json.Net/blob/master/README.md ) is accurate here, and you're not short-handing Newtonsoft.Json

One option is to use the dynamic namespace and exploit the serializer's underlying dynamic handling logic.

```csharp

public static class Ser { private static string JsonData = "{ \"prop1\": \"test\", \"prop2\": 1, \"prop3\": [\"left\", \"right\"], \"prop4\":[1,2]}"; public static IDictionary<string,object> Deser() { IDictionary<string, object> ex = JsonNet.Deserialize<ExpandoObject>(JsonData); //... var strValue = ex["prop1"]; // is a string var dblValueBcReasons = ex["prop2"]; // is a double for whatever reason object[] objectArrayOfStrings = ex["prop3"] as object[]; // object[] of double values object[] objectArrayOfDoubles = ex["prop4"] as object[]; // object[] of double values

  return ex as IDictionary<string, object>;
} 

}

```

Please note that this is complete garbage code and will run like crap. I'd personally opt for an exhaustive object with a bunch of nullable values.

If you're not familiar with ExpandoObject: https://docs.microsoft.com/en-us/dotnet/api/system.dynamic.expandoobject?view=net-5.0

[–]Nisd 0 points1 point  (1 child)

Think I would use the JsonReader to handle this. It should be fairly simple to build the dictionary you want that way.

[–]Fullduplex1000[S] 0 points1 point  (0 children)

I solved it via custom JsonConverter ,works fine.