zoukankan      html  css  js  c++  java
  • 【02-16】gson读取配置信息

    
    
    	@SuppressWarnings({ "rawtypes", "unchecked" })
    	public static Map<String, Map<Integer, String>> getNodeAlarmInfoConfig(String filePath) {
    		InputStream is = JsonTest.class.getResourceAsStream("/META-INF/test.json");
    		String result;
    		try {
    			result = IOUtils.toString(is);
    		} catch (IOException e) {
    			e.printStackTrace();
    			return new HashMap<>();
    		}
    		Map<String, Map<Integer, String>> config = new HashMap<>();
    		HashMap map = new Gson().fromJson(result, HashMap.class);
    		Set<Map.Entry> entrySet = map.entrySet();
    		for (Map.Entry entry : entrySet) {
    			String key = (String) entry.getKey();
    			Map<Integer, String> innerMap = new HashMap<>();
    			for (Object obj : (List) entry.getValue()) {
    				Double innerKey = (Double) (((Map) obj).get("key"));
    				innerMap.put(innerKey.intValue(), (String) ((Map) obj).get("value"));
    			}
    			config.put(key, innerMap);
    		}
    		return config;
    	}
    
  • 相关阅读:
    su 命令切换用户带来的问题
    系统无法启动
    Linux单用户模式
    反射
    propety/静态方法
    内置方法,序列化模块
    第1月5周3天
    第1月4周5天
    第1月4周4日
    第1月4周3日
  • 原文地址:https://www.cnblogs.com/achievec/p/6411555.html
Copyright © 2011-2022 走看看