bodyAsJsonList<T, F> method

Future<List<T>> bodyAsJsonList <T, F>({Encoding encoding: conv.utf8, T convert(F d) })

Decodes JSON body of the request as List

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

Implementation

Future<List<T>> bodyAsJsonList<T, F>(
    {conv.Encoding encoding: conv.utf8, T convert(F d)}) async {
  final String text = await bodyAsText(encoding);
  final List ret = conv.json.decode(text);
  if (convert != null) return ret.cast<F>().map(convert).toList();
  return ret.cast<T>();
}