S.D.
S.D.

Reputation: 5867

Parsing JSON to string key and values

Is there a way to parse a JSON as a Map<String, String> instead of Map<String, dynamic> when using Dart's json.decode.

For example with JSON of:

{
 'a': 2,
 'b': 'c'
}

It would parse into:

{
 'a': '2',
 'b': 'c'
}

Upvotes: 0

Views: 108

Answers (1)

Kevin Moore
Kevin Moore

Reputation: 6171

Sadly, no. The code for decoding a Map starts with a Map<String, dynamic> and adds values as they are read, so there is no way to make the value type more specific.

Look into these for other options:

Upvotes: 1

Related Questions