Subversion Repositories SmartDukaan

Rev

Rev 13538 | Rev 13540 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13538 Rev 13539
Line 93... Line 93...
93
				.registerTypeAdapter(Object.class, new NaturalDeserializer());
93
				.registerTypeAdapter(Object.class, new NaturalDeserializer());
94
		Gson gson = gsonBuilder.create();
94
		Gson gson = gsonBuilder.create();
95
		Type t = new TypeToken<Map<String,Object>>() {}.getType();
95
		Type t = new TypeToken<Map<String,Object>>() {}.getType();
96
		Map<String, Object> postMap =  gson.fromJson(postResponse, t);
96
		Map<String, Object> postMap =  gson.fromJson(postResponse, t);
97
		log.info("postMap.get(\"status\")=======" + postMap.get("status"));
97
		log.info("postMap.get(\"status\")=======" + postMap.get("status"));
98
		if ("0".equals(postMap.get("status"))) {
98
		if (0 == ((Integer)postMap.get("status")).intValue()) {
99
			resultMap.put(ERR_CODE, Errors.CAPTURE_FAILURE.code);
99
			resultMap.put(ERR_CODE, Errors.CAPTURE_FAILURE.code);
100
			resultMap.put(ERROR, (String)postMap.get("msg"));
100
			resultMap.put(ERROR, (String)postMap.get("msg"));
101
		} else if ("1".equals(postMap.get("status"))){
101
		} else if (1 == ((Integer)postMap.get("status")).intValue()){
102
			log.info("postMap.containsKey(\"bank_ref_num\")========" + postMap.containsKey("bank_ref_num")); 
102
			log.info("postMap.containsKey(\"bank_ref_num\")========" + postMap.containsKey("bank_ref_num")); 
103
			resultMap.put(REF_NO, (String) postMap.get("bank_ref_num"));
103
			resultMap.put(REF_NO, (String) postMap.get("bank_ref_num"));
104
			if(postMap.get("txn_update_id")!= null) {
104
			if(postMap.get("txn_update_id")!= null) {
105
				resultMap.put("txn_update_id", (String)postMap.get("txn_update_id"));
105
				resultMap.put("txn_update_id", (String)postMap.get("txn_update_id"));
106
			}
106
			}
Line 257... Line 257...
257
			return map;
257
			return map;
258
		}
258
		}
259
	}
259
	}
260
	
260
	
261
	public static void main (String arg[]){
261
	public static void main (String arg[]){
262
		String jsonText = "{\"amit\":\"Wonderful\", \"babu\":{\"a\":\"Awesome\"}}";
262
		String jsonText = "{\"amit\":0, \"babu\":{\"a\":\"Awesome\"}}";
263
		System.out.println(jsonText);
263
		System.out.println(jsonText);
264
		GsonBuilder gsonBuilder = new GsonBuilder();
264
		GsonBuilder gsonBuilder = new GsonBuilder();
265
		gsonBuilder
265
		gsonBuilder
266
				.registerTypeAdapter(Object.class, new NaturalDeserializer());
266
				.registerTypeAdapter(Object.class, new NaturalDeserializer());
267
		Gson gson = gsonBuilder.create();
267
		Gson gson = gsonBuilder.create();
-
 
268
		Type t = new TypeToken<Map<String,Object>>() {}.getType();
-
 
269
		Map<String, Object> postMap =  gson.fromJson(jsonText, t);
268
		Map<String, Object> postMap = (Map<String, Object>) gson.fromJson(
270
		/*Map<String, Object> postMap = (Map<String, Object>) gson.fromJson(
269
				jsonText, Object.class);
271
				jsonText, Object.class);*/
270
		System.out.println(postMap);
272
		System.out.println(postMap);
271
		System.out.println(new SimpleDateFormat().format(new Date()));
273
		System.out.println(0 == ((Integer)postMap.get("amit")).intValue());
272
	}
274
	}
273
}
275
}