zoukankan      html  css  js  c++  java
  • 对JSON数据的解析(数据推送接口)

    package com.liuqi.www;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.PostMapping;
    import org.springframework.web.bind.annotation.RequestBody;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    @Controller("TestController")
    @RequestMapping(value = "/testController",method = RequestMethod.POST)
    public class TestController{
        
        @RequestMapping(value="/test",method = RequestMethod.POST)
        @ResponseBody
        public Map<String,Object> test(@RequestBody Map<String,Object> parameter){
            //请求的数据相关信息
            Map<String,String> head = (Map<String,String>)parameter.get("head");
            
            //js端生成的请求流水号
            String reqId = head.get("reqId");
            
            //请求时间
            String times = head.get("times");
            
            //请求从哪个功能点过来的
            String compId = head.get("compId");
            
            //存放数据描述信息
            Map<String,Object> info = (Map<String,Object>)parameter.get("info");
            
            //数据类型
            String dataType = (String)info.get("dataType");
            
            //操作类型
            String opType = (String)info.get("opType");
            
            //存放数据的对象
            Object date = info.get("date");
            
            //做处理
            
            
            //返回结果
            Map<String,Object> result = new HashMap<>();
            
            Map<String,Object> resultHead = new HashMap<>();
            
            //给head里面放数据
            
            Map<String,Object> resultInfo = new HashMap<>();
            
            //给info里面放数据
            
            result.put("head", resultHead);
            result.put("info", resultInfo);
            return result;
        }
        
    }

    将JSON数据解析成自己需要的对象,来进行相关的操作,通过参数接收操作后的数据,来进行返回码的判断,将返回码显示给上一级查看

  • 相关阅读:
    商务通服务器版LR_Data目录下相关配置文件
    Python入门神图
    你不知道的JavaScript-2.词法作用域
    你不知道的JavaScript-1.作用域是什么
    linux服务器对外打包处理
    C# Form 关闭按钮灰化
    Spread常用属性
    Spread 常用属性
    C#打开关闭窗体事件顺序
    sqlserver如何使用日期计算
  • 原文地址:https://www.cnblogs.com/darui/p/9077340.html
Copyright © 2011-2022 走看看