MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / serializeFromSerializable

Method serializeFromSerializable

src/main/java/fieldbox/io/EDN.java:288–313  ·  view source on GitHub ↗
(Tag tag)

Source from the content-addressed store, hash-verified

286 }
287
288 public us.bpsm.edn.printer.Printer.Fn<?> serializeFromSerializable(Tag tag) {
289 return (o, writer) -> {
290 try {
291 ByteArrayOutputStream baos = new ByteArrayOutputStream();
292 ObjectOutputStream oos = new ObjectOutputStream(baos);
293 oos.writeObject(o);
294 oos.close();
295 byte[] bytes = baos.toByteArray();
296
297 byte[] b2 = Base64.getEncoder()
298 .encode(bytes);
299
300 String v = new String(b2);
301
302 Map<Object, Object> mm = new LinkedHashMap<>();
303
304 mm.put(Keyword.newKeyword("base64"), v);
305
306 writer.printValue(tag)
307 .printValue(mm);
308
309 } catch (IOException e) {
310 e.printStackTrace();
311 }
312 };
313 }
314
315// public us.bpsm.edn.printer.Printer.Fn<?> serializeToToString(Tag tag) {
316// return (o, writer) -> {

Callers 1

EDNMethod · 0.95

Calls 4

encodeMethod · 0.80
closeMethod · 0.65
writeObjectMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected