我正在使用亚马逊的云服务开发一个webapp,我需要使用JSON对象.我的项目是如何设置的,我有一个HTML表单,用户将填写他们的信息并提交.提交后,数据将被放入在线数据库,并向他们发送确认电子邮件.在我将数据提交到数据库之前,我需要将所有数据放入JSON对象中.我的servlet,用Java完成,看起来像这样:
public class FormHandling extends HttpServlet {
//doGet function
public void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// In this part of the code I take in the user data and build an HTML
// page and return it to the user
// Create String Mapping for User Data object
Map<String,Object> userData = new HashMap<String,Object>();
// Map the names into one struct. In the code below we are creating
// values for the nameStruct from the information …Run Code Online (Sandbox Code Playgroud)