All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.eshore.tools.TestJsonEncode Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
package com.eshore.tools;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.eshore.uas.extensions.IPropertiesEncoder;
import com.eshore.uas.extensions.option.DefaultProperisEncoder;
import com.eshore.uas.extensions.option.PropertiesEncoder;
import com.eshore.uas.system.option.Vcckey;

public class TestJsonEncode {

	public static void main(String[] args) {
		IPropertiesEncoder dpe = new IPropertiesEncoder() {

			@Override
			public String encode(String key, String value) {
				if(accept(key))
				return "#"+value;
				return value;
			}

			@Override
			public boolean accept(String key) {
				return "cccc".equals(key)||"ddd".equals(key)||"test1".equals(key);
			}};
			
			dpe=new PropertiesEncoder(new Vcckey().getkey("abcd") );
		Map map = new HashMap();
		map.put("test","aaaa");
		map.put("name","aaaa");
		map.put("cellphone", "13777777777");
		map.put("id","bbb");
		map.put("roles", new String [] {"aaa","ccc","bbb"});
		List list =new ArrayList();
		map.put("ddd", list);
		list.add("1");
		list.add("2");
		list.add("3");
		String str = Json2StringEncoder.asJsonString(map, dpe, "test");
		System.out.println(str);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy