bodyAsJsonMap method

Future<Map> bodyAsJsonMap({
  1. Encoding encoding = conv.utf8,
})

Decodes JSON body of the request as Map

Example: final server = new Jaguar(); server.post('/api/book', (Context ctx) async { // Decode request body as JSON Map final Map<String, dynamic> json = await ctx.req.bodyAsJsonMap(); // ... }); await server.serve();

Implementation

Future<Map> bodyAsJsonMap({conv.Encoding encoding = conv.utf8}) async {
  final String text = await bodyAsText(encoding);
  final ret = conv.json.decode(text);
  return ret;
}