Linked Questions

3 votes
1 answer
20k views

converting dictionary string string to json string [duplicate]

How can i convert my dictionary Dictionary<string,string> to JSON string and then again convert from JSON string to Dictionary<string,string> in c#?
Bravo11's user avatar
  • 908
1 vote
1 answer
4k views

How to deserialize the json array of objects to dictionary [duplicate]

I have a Json string "[{'SymptID': '" + MidID + "', 'ALvl' : '" +JawLvl + "'}, {'SymptID': '" + BckID + "', 'ALvl' : '" + PanLvl + "'}, {'SymptID': '" + SysID + "', 'ALvl' : '" + wPLvl + "'}]" &...
deepu's user avatar
  • 2,013
0 votes
3 answers
2k views

How to parse json key - value to object C# from Request.Properties["MS_QueryNameValuePairs"] [duplicate]

I have string json as "[{\"Key\":\"a\",\"Value\":\"1\"},{\"Key\":\"b\",\"Value\":\"2\"}}]" I want parse to object class abc{ public string a{get; set;} public string b{get; set;} } Please, help ...
Thoại Nguyễn's user avatar
0 votes
1 answer
815 views

Deserialize json to Dictionary<string, string> in C# applicaiton [duplicate]

I have this class: public class ParseJson { private HttpClient _client; public ParseJson() { _client = new HttpClient(); } public async Task<...
runnerpaul's user avatar
  • 6,524
2 votes
1 answer
528 views

converting dynamic json model to c# object [duplicate]

i m working on a .net project. I need to convert a json model (which has dynamicly changed numerical node name) to csharp class. Second node's name is changing dynamically, thats why i can not write ...
Emre Erarslan's user avatar
0 votes
0 answers
286 views

Map Dictionary<string, string> to simple javascript/json associative array [duplicate]

I have a Dictionary that i want to JSON-ify into a simple lookup-object. Examine this code: var dictionary = new Dictionary<string, string> {{"test", "value"}, {"test2", "value2"}}; If I Json ...
Per Hornshøj-Schierbeck's user avatar
0 votes
2 answers
275 views

Convert JSON Key into Object [duplicate]

I have a scnerio where i donot know the names of the keys so properties can;t be created beforehand. The JSON needs to be parsed and loaded into Dictionary that is present in a class. The format of ...
abdul's user avatar
  • 157
0 votes
0 answers
236 views

Parsing JSON with C# [duplicate]

Currently I have a JSON body that I would like to deserialize into a list of objects in C#. The JSON looks very similar to this: { "123": { "id": "123", "description": "Element 1",...
Manky Fox's user avatar
0 votes
1 answer
217 views

c# Parse JSON with no reference class? [duplicate]

I have a JSON similar to the following: { "type": "FeatureCollection", "totalFeatures": "unknown", "features": [ { "type": "Feature", "id": "xxx", ...
teraxxx's user avatar
  • 55
0 votes
0 answers
156 views

Json Convert all elements as key value pair [duplicate]

How to convert all elements as key value pair in json. EX : { "Id": " 357342524563456678", "title": "Person", "language": "eng", "questionAnswer": [ { "...
Karthikeyan's user avatar
-2 votes
3 answers
94 views

How to setup json deserizlization from Object to Array in C# [duplicate]

I got this strange API response from external service: { "Columns": { "1": { "Fuels": [ "1", "10", &...
hamaronooo's user avatar
0 votes
0 answers
28 views

JS object from Node server to Unity [duplicate]

I am trying to deserialize this js object in Unity { "1":{ "id":1, "name":"John", "score":0, "character":0, ...
Miika Anundi's user avatar
428 votes
4 answers
421k views

Convert Linq Query Result to Dictionary

I want to add some rows to a database using Linq to SQL, but I want to make a "custom check" before adding the rows to know if I must add, replace or ignore the incomming rows. I'd like to keep the ...
Tipx's user avatar
  • 7,435
119 votes
5 answers
137k views

Convert JObject into Dictionary<string, object>. Is it possible?

I have a web API method that accepts an arbitrary json payload into a JObject property. As such I don't know what's coming but I still need to translate it to .NET types. I would like to have a ...
tucaz's user avatar
  • 6,634
78 votes
8 answers
116k views

Deserialize JSON to anonymous object

In C#, I have successfully serialized an anonymous object into JSON by use of code like this... var obj = new { Amount = 108, Message = "Hello" }; JavaScriptSerializer serializer = new ...
jdavis's user avatar
  • 8,485
29 votes
3 answers
96k views

Parsing JSON key/value pairs with JSON.NET

I have a .NET project. I'm using the JSON.NET library. I need to use this library to parse some JSON. My JSON looks like this: {"1":"Name 1","2":"Name 2"} The object is really just a list of key/...
JQuery Mobile's user avatar
9 votes
2 answers
67k views

Deserializing JSON into string array

I just started dabbling with C#, and I've been banging my head over JSON deserialization for a while now. I'm using Newtonsoft.Json library. I'm expecting just a json response of an array of ...
Chris's user avatar
  • 7,300
6 votes
6 answers
30k views

JSON array to C# Dictionary

How do I convert a JSON array like this [{"myKey":"myValue"}, {"anotherKey":"anotherValue"}] to a C# Dictionary with json.net or system classes. json.net can serialize directly to a dictionary, but ...
bbsimonbb's user avatar
  • 28.1k
8 votes
4 answers
23k views

Using JSON.NET to access JSON attributes to create a C# dictionary

I want to convert what is ultimately a dictionary in JSON to a C# dictionary without much ado. Am I barking up the wrong tree by using the JSON.NET library here? The JArray class doesn't want to give ...
PandaWood's user avatar
  • 8,216
4 votes
3 answers
29k views

How to parse nested JSON data structure

In a Windows Phone app I need to parse JSON data. I am able to get the values for keys which aren't nested. But if the JSON has arrays inside arrays, then how do I extract values from the JSON file? ...
Shagufta Oliveyu Methwani's user avatar
5 votes
4 answers
13k views

Complex JSON Web Token Array in webapi with OWIN

I'm in process of trying to learn JWT and ouath. I have came across form of JWT which would help me in development of my authorization server. The format I came across is following : { iat: ...
erPe's user avatar
  • 558
5 votes
4 answers
7k views

C# - deserialize JSON into ValueTuple

I'm trying to deserialize [{"foo": "1", "bar": false}, {"foo": "2", "bar": false}] into List<(string, bool)> type: JsonConvert.DeserializeObject<List<(string foo, bool bar)>>(...
anatol's user avatar
  • 1,694
5 votes
4 answers
6k views

How can I accept a 'dictionary' of data as a custom .NET attribute parameter?

I recently discovered that a .NET attribute can only contain primitive types, strings, enums, objects, and single parameter arrays of these types as discussed here. I have the need to accept an ...
NightOwl888's user avatar
  • 56.2k
3 votes
3 answers
19k views

Can you deserialize a JSON string to a C# array?

I'm trying to deserialize the JSON string [{ "key" : "1", "value" : "open"}, {"key" : "2", "value" : "closed"}, {"key" : "3", "value" : "pending"}] into a C# array. I'm getting the error "No ...
user avatar
4 votes
2 answers
4k views

Deserializing JSON when key values are unknown

How do I deserialize JSON with JSON.net in C# where the key values are not known (they are MAC addresses of multiple devices). There could be one or more key entries. { "devices": { "...
bbs_chad's user avatar
1 vote
1 answer
12k views

Deserialize Json.net JSON File directly to a C# dictionary type?

Is there a way using JSON.NET to deserialize a file type directly to a C# dictionary type? For example: using (StreamReader file = File.OpenText(myFileName)) { Dictionary<string, int> ...
Michael Codeaholic's user avatar
2 votes
1 answer
9k views

Deserialize json to list of KeyValue pairs

I have the following json: [ { "key":"key1", "value":"val1" }, { "key":"key2", "value":"val2" } ] How can I deserialize it into an list/array of NameValuePair<...
rboarman's user avatar
  • 8,267
1 vote
2 answers
16k views

C# JSON Parsing

I have problems parsing some JSON data: { "title": "LED SIDE DIRECTION INDICATOR 9-33V CATEGORY 6, 19cm CABLE CHROME BASE LED AUTO LAMPS", "user_price": { "inc_tax_value": 34.067, ...
Aaron Gibson's user avatar
  • 1,330
0 votes
1 answer
34k views

How do I convert json string to key\value pairs?

I want to take all the key-value pairs after the \"tags\" under "instanceData" and make them key-value pairs under "properties". I have this... { "id": "/subscriptions/1234abcd-ab12-12ab-12ab-...
daGooch's user avatar
1 vote
3 answers
10k views

deserialize json to class (manually with reflection)

I am working with a cut down version of C# 3.5 on a platform that doesn't have the flexibility of using third party libraries. While I can parse JSON (using a json stream reader), I am not sure how ...
Bob Smith's user avatar
  • 153

15 30 50 per page
1
2 3 4 5