score:0
var dicvalues = new dictionary<string,string>(); // this dictionary contains key value pair result
dynamic res = jsonconvert.deserializeobject<dynamic>(file.readalltext("data.json");
dynamic availablefields = res["fields"];
if (availablefields != null)
{
foreach (var field in availablefields)
dicvalues.add(field.name, field.value["value"].value);
}
score:1
var result = new dictionary<string, string>();
foreach (var field in obj.fields)
{
result.add(field.name, convert.tostring(field.value.value));
}
score:2
var dict = jobject.parse(file.readalltext("data.json"))["fields"]
.cast<jproperty>()
.todictionary(x => x.name, x => (string)x.value["value"]);
Source: stackoverflow.com
Related Query
- Make dynamic dictionary from json file
- How do you make a tuple or keyvalue pair json serialize like a dictionary in C#
- Get a list from a dynamic json result
- Make .dbml file in a class library use connectionstring from config file without subclassing it
- C# - Load dictionary of Hashsets from an XML file using Linq
- How to bind dynamic multi listing data from xml file in windows phone 7?
- LINQ Webservice GET list of similar products from JSON file
- dynamic value in parent node in json from c# linq
- Linq query for building a dictionary from a reg file
- How to convert data from two different locations in JSON file to a key(string) and value(double) within a C# dictionary, using Linq?
- Getting error while parsing json response from a dynamic {System.RuntimeType} variable
- forming json from dictionary keys in c#
- get a node value from json file
- How can I filter a dictionary using LINQ and return it to a dictionary from the same type
- Remove a Key from Dictionary by key name
- How to select multiple values from a Dictionary using Linq as simple as possible
- How do I convert from a Dictionary to a SortedDictionary using LINQ in C#?
- jqgrid with asp.net webmethod and json working with sorting, paging, searching and LINQ -- but needs dynamic operators
- How to create a csv file from List<String[]>
- LINQ: Getting Keys for a given list of Values from Dictionary and vice versa
- Creating a dictionary from another dictionary using LINQ
- Make CSV from list of string in LINQ
- Use LINQ and C# to make a new List from an old List
- Use reflection to make dynamic LINQ statements in C#
- LINQ to XML - Load XML fragments from file
- How to create a dynamic LINQ select projection function from a string[] of names?
- Execution-Deferred IQueryable<T> from Dynamic Linq?
- How to get item from dictionary by value of property
- Generate POCO objects from xml file
- How to SELECT from any spreadsheet in Excel File using OleDbDataAdapter
More Query from same tag
- How to get Max Date in Linq?
- Linq To Sql - Update a value when another value changes
- Get data using Date and Time from sql in C#
- Bitmask (flags) enum beyond 64 with bitarray with logical grouping stored in database
- How use Long type for Skip in Linq
- incorrect login linq and datatable
- Linq: Adding Extra 'Where' Clause Gives Random Results
- Is there a way to ONLY add tables to an edmx file?
- C# CopyToDataTable method not working
- Creating an Object List from another List Object LINQ Lambda
- The model item passed into the dictionary is of type 'System.Collections.Generic.Lis
- how to loop through a array of objects and match to a database and return matching with linq
- LINQ getting a list from another list of entities
- In place intersection of two collections of different types
- Appending dynamic where statements in LINQ to Entities but as an OR operator instead of AND
- Select the longest string where subparts is the same from list
- Grouping and projection with mongodb C# driver
- Error convert Datetime to nullable Datetime in Linq
- Can Scala collection's seq/par/view/force be seen as a violation of the uniform return type principle?
- LINQ need to parse JSON out of a column
- LINQ to SQL, using subquery with IN operator
- system.linq groupby more than one element
- How do i use linq to do this?
- Nested GroupBy extension method in LINQ
- Spliting up long linq queries for improved maintainability
- XElement to List in c#
- c# LinqtoTwitter getting ScreenName/UserID from connection context
- The LINQ expression could not be translated. Eiither rewrite the query in a form that can be translated
- A clever alternative in LINQ for iterating over HashSet<string>
- Group by in the case of data in the database and data when displaying inconsistencies