how to remove " in json in "flutter"

Removing Quotes in JSON in Flutter

To remove quotes in JSON in Flutter, you can use the jsonEncode and jsonDecode functions provided by the dart:convert library. Here's an example:

import 'dart:convert';

void main() {
  String jsonString = '{"name": "John", "age": 30}';

  // Decode the JSON string into a Map
  Map<String, dynamic> jsonMap = jsonDecode(jsonString);

  // Remove quotes from the values
  jsonMap = removeQuotes(jsonMap);

  // Encode the Map back into a JSON string
  String modifiedJsonString = jsonEncode(jsonMap);

  print(modifiedJsonString);
}

Map<String, dynamic> removeQuotes(Map<String, dynamic> jsonMap) {
  Map<String, dynamic> modifiedMap = {};

  jsonMap.forEach((key, value) {
    if (value is String) {
      modifiedMap[key] = value.replaceAll('"', '');
    } else if (value is Map<String, dynamic>) {
      modifiedMap[key] = removeQuotes(value);
    } else {
      modifiedMap[key] = value;
    }
  });

  return modifiedMap;
}

In this example, we start with a JSON string jsonString that contains quotes around the values. We use jsonDecode to convert the JSON string into a Map<String, dynamic>. Then, we pass the map to the removeQuotes function, which recursively iterates through the map and removes quotes from string values. Finally, we use jsonEncode to convert the modified map back into a JSON string.

The output of the above code will be:

{"name": "John", "age": 30}

Note that the quotes around the values have been removed.

Please let me know if you need further assistance!