本文整理汇总了Java中net.minidev.json.JSONValue.toJSONString方法的典型用法代码示例。如果您正苦于以下问题:Java JSONValue.toJSONString方法的具体用法?Java JSONValue.toJSONString怎么用?Java JSONValue.toJSONString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minidev.json.JSONValue
的用法示例。
在下文中一共展示了JSONValue.toJSONString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testF4
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
public void testF4() {
String test = "51ee88";
JSONObject o = new JSONObject();
o.put("a", test);
String comp = JSONValue.toJSONString(o, JSONStyle.MAX_COMPRESS);
assertEquals("{a:51ee88}", comp);
o = JSONValue.parse(comp, JSONObject.class);
assertEquals(o.get("a"), test);
}
示例2: setUp
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
@Before
public void setUp(){
dbCredential = DBCredential.builder()
.hostName("HOST")
.build();
dbCredentialString = JSONValue.toJSONString(dbCredential);
}
示例3: testF2
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
public void testF2() {
String test = "51e+88";
JSONObject o = new JSONObject();
o.put("a", test);
String comp = JSONValue.toJSONString(o, JSONStyle.MAX_COMPRESS);
assertEquals("{a:\"51e+88\"}", comp);
o = JSONValue.parse(comp, JSONObject.class);
assertEquals(o.get("a"), test);
}
示例4: testSerObjBool1
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
public void testSerObjBool1() throws Exception {
String s = "{\"data\":true}";
T4 r = new T4();
r.data = true;
String s2 = JSONValue.toJSONString(r);
assertEquals(s, s2);
}
示例5: testSerObjBool2
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
public void testSerObjBool2() throws Exception {
String s = "{\"data\":true}";
T5 r = new T5();
r.data = true;
String s2 = JSONValue.toJSONString(r);
assertEquals(s, s2);
}
示例6: testBigDecimal
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
/**
* test BigDecimal serialization
*/
public void testBigDecimal() {
HashMap<String, Object> map = new HashMap<String, Object>();
BigDecimal bigDec = new BigDecimal(bigStr + "." + bigStr);
map.put("big", bigDec);
String test = JSONValue.toJSONString(map);
String result = "{\"big\":" + bigStr + "." +bigStr + "}";
assertEquals(result, test);
JSONObject obj = (JSONObject)JSONValue.parse(test);
assertEquals(bigDec, obj.get("big"));
assertEquals(bigDec.getClass(), obj.get("big").getClass());
}
示例7: testSerObjMixtePrim
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
public void testSerObjMixtePrim() throws Exception {
T3 r = new T3();
r.name = "B";
r.age = 120;
r.cost = 12000;
r.flag = 3;
r.valid = true;
r.name = "B";
r.f = 1.2F;
r.d = 1.5;
r.l = 12345678912345L;
String s = JSONValue.toJSONString(r);
assertEquals(MuliTyepJson, s);
}
示例8: test_dummy
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
public void test_dummy() throws IOException {
@SuppressWarnings("unused")
ParseException e = null;
JSONValue.toJSONString(true, JSONStyle.MAX_COMPRESS);
//Assert.assertEquals(true, true);
}
示例9: testF1
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
public void testF1() {
String test = "51e88";
JSONObject o = new JSONObject();
o.put("a", test);
String comp = JSONValue.toJSONString(o, JSONStyle.MAX_COMPRESS);
assertEquals("{a:\"51e88\"}", comp);
o = JSONValue.parse(comp, JSONObject.class);
assertEquals(o.get("a"), test);
}
示例10: testS1
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
public void testS1() throws Exception {
Beans beans = new Beans();
String s = JSONValue.toJSONString(beans, JSONStyle.MAX_COMPRESS);
assertEquals("{}", s);
s = JSONValue.toJSONString(beans, JSONStyle.NO_COMPRESS);
if (s.startsWith("{\"b")) {
assertEquals("{\"b\":null,\"a\":null}", s);
} else {
assertEquals("{\"a\":null,\"b\":null}", s);
}
beans.a = "a";
s = JSONValue.toJSONString(beans, JSONStyle.MAX_COMPRESS);
assertEquals("{a:a}", s);
}
示例11: testBigInteger
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
/**
* test BigInteger serialization
*/
public void testBigInteger() {
HashMap<String, Object> map = new HashMap<String, Object>();
BigInteger bigInt = new BigInteger(bigStr);
map.put("big", bigInt);
String test = JSONValue.toJSONString(map);
String result = "{\"big\":" + bigStr + "}";
assertEquals(result, test);
JSONObject obj = (JSONObject)JSONValue.parse(test);
assertEquals(bigInt, obj.get("big"));
assertEquals(bigInt.getClass(), obj.get("big").getClass());
}
示例12: testF1
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
public void testF1() {
String test = "51e88";
JSONObject o = new JSONObject();
o.put("a", test);
String comp = JSONValue.toJSONString(o, JSONStyle.MAX_COMPRESS);
assertEquals("{a:\"51e88\"}", comp);
o = (JSONObject)JSONValue.parse(comp);
assertEquals(o.get("a"), test);
}
示例13: testF2
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
public void testF2() {
String test = "51e+88";
JSONObject o = new JSONObject();
o.put("a", test);
String comp = JSONValue.toJSONString(o, JSONStyle.MAX_COMPRESS);
assertEquals("{a:\"51e+88\"}", comp);
o = (JSONObject)JSONValue.parse(comp);
assertEquals(o.get("a"), test);
}
示例14: testF3
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
public void testF3() {
String test = "51e-88";
JSONObject o = new JSONObject();
o.put("a", test);
String comp = JSONValue.toJSONString(o, JSONStyle.MAX_COMPRESS);
assertEquals("{a:\"51e-88\"}", comp);
o = (JSONObject)JSONValue.parse(comp);
assertEquals(o.get("a"), test);
}
示例15: testF4
import net.minidev.json.JSONValue; //导入方法依赖的package包/类
public void testF4() {
String test = "51ee88";
JSONObject o = new JSONObject();
o.put("a", test);
String comp = JSONValue.toJSONString(o, JSONStyle.MAX_COMPRESS);
assertEquals("{a:51ee88}", comp);
o = (JSONObject)JSONValue.parse(comp);
assertEquals(o.get("a"), test);
}