Skip to content
This repository has been archived by the owner on Jun 12, 2020. It is now read-only.

analogweb/jackson-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Analog Web Framework Jackson Plugin

Build Status

This plugin enables parse JSON format request.(application/json)

Also rendering JSON using Jackson's ObjectMapper.

Example

import static org.analogweb.core.response.BasicResponses.json;

import org.analogweb.annotation.Route;
import org.analogweb.annotation.Get;
import org.analogweb.annotation.Post;
import org.analogweb.annotation.RequestFormats;
import org.analogweb.core.MediaTypes;
import org.analogweb.core.response.Json;
import org.analogweb.jackson.JsonType;

@Route("/")
public class Hello {

  @Route("json")
  // Add Content-Type limitation. (Response 415 when invalid Content-Type detected.)
  // Without this annotation there is no Content-Type limitation. (Argument is null.)
  @RequestFormats(MediaTypes.APPLICATION_JSON)
  @Post
  public String postJson(@JsonType Bean bean) {
     // Obtain requested JSON as object.
     ...
  }

  @Route("json")
  @Get
  public Json getJson() {
    ...
    Bean bean
    ...
    // Response JSON using Jackson's ObjectMapper.
    return json(bean)
  }

}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages