use of org.noggit.CharArr in project disgear by yangbutao.
the class ZkStateReader method fromJSON.
public static Object fromJSON(byte[] utf8) {
// convert directly from bytes to chars
// and parse directly from that instead of going through
// intermediate strings or readers
CharArr chars = new CharArr();
ByteUtils.UTF8toUTF16(utf8, 0, utf8.length, chars);
JSONParser parser = new JSONParser(chars.getArray(), chars.getStart(), chars.length());
try {
return ObjectBuilder.getVal(parser);
} catch (IOException e) {
// should never happen w/o using real
throw new RuntimeException(e);
// IO
}
}
use of org.noggit.CharArr in project disgear by yangbutao.
the class ZkStateReader method toJSON.
public static byte[] toJSON(Object o) {
CharArr out = new CharArr();
// indentation by default
new JSONWriter(out, 2).write(o);
return toUTF8(out);
}
use of org.noggit.CharArr in project lucene-solr by apache.
the class Utils method fromJSON.
public static Object fromJSON(byte[] utf8) {
// convert directly from bytes to chars
// and parse directly from that instead of going through
// intermediate strings or readers
CharArr chars = new CharArr();
ByteUtils.UTF8toUTF16(utf8, 0, utf8.length, chars);
JSONParser parser = new JSONParser(chars.getArray(), chars.getStart(), chars.length());
try {
return ObjectBuilder.getVal(parser);
} catch (IOException e) {
// should never happen w/o using real IO
throw new RuntimeException(e);
}
}
use of org.noggit.CharArr in project lucene-solr by apache.
the class Utils method toJSON.
public static byte[] toJSON(Object o) {
if (o == null)
return new byte[0];
CharArr out = new CharArr();
// indentation by default
new JSONWriter(out, 2).write(o);
return toUTF8(out);
}
use of org.noggit.CharArr in project lucene-solr by apache.
the class TestDelegationTokenResponse method getNestedMapJson.
private String getNestedMapJson(String outerKey, String innerKey, Object innerValue) {
CharArr out = new CharArr();
JSONWriter w = new JSONWriter(out, 2);
Map<String, Object> innerMap = new HashMap<String, Object>();
innerMap.put(innerKey, innerValue);
Map<String, Map<String, Object>> outerMap = new HashMap<String, Map<String, Object>>();
outerMap.put(outerKey, innerMap);
w.write(outerMap);
return out.toString();
}
Aggregations