UtilJsonParseJsonLightweightTValue(String) Method
Parses a JSON string and returns a
DictionaryTKey, TValue
representing the JSON key-value pairs, where all the values are casted to the specified 'TValue' type.
Note: This method is a lightweight, free dependency solution to parse a JSON string.
Original author:
https://stackoverflow.com/a/13192508/1248295
Consider to use it only when adding external references (like JSON.net) to the project is
either extremely problematic or impossible.
Namespace: DevCase.Core.DataProcessing.JsonAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static Dictionary<string, TValue> ParseJsonLightweight<TValue>(
string json
)
Public Shared Function ParseJsonLightweight(Of TValue) (
json As String
) As Dictionary(Of String, TValue)
Dim json As String
Dim returnValue As Dictionary(Of String, TValue)
returnValue = UtilJson.ParseJsonLightweight(json)
public:
generic<typename TValue>
static Dictionary<String^, TValue>^ ParseJsonLightweight(
String^ json
)
static member ParseJsonLightweight :
json : string -> Dictionary<string, 'TValue>
No code example is currently available or this language may not be supported.
- json String
-
The JSON string to parse.
- TValue
DictionaryString,
TValue
A
DictionaryTKey, TValue representing the JSON key-value pairs.
This is a code example.
No code example is currently available or this language may not be supported.
Dim json As String = "{
""name"": ""John Doe"",
""age"": 30,
""city"": ""New York""
}"
Dim dict As Dictionary(Of String, String) = ParseJsonLightweight(Of String)(json)
For Each key As String In dict.Keys
Console.WriteLine($"Key: {key}, Value: {dict(key)}")
Next
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.