Más contenido relacionado La actualidad más candente (19) Similar a Java EE 8 - Work in progress (20) Más de David Delabassee (20) Java EE 8 - Work in progress14. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved.* @delabassee
JSONQP*1.1
• Patch*is*a*JSON*document*
– Array*of*objects*/*operations*for*modifying*a*JSON*document*
– add,*replace,*remove,*move,*copy,*test
JSONMPatch&–&IETF&RFC&6902
[)
))){"op":"replace","path":"/0/phones/mobile","value":"650K111K222"},)
))){"op":"remove","path":"/1"})
]
14
15. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved.* @delabassee
JSONQP*1.1
[)
){)
))"op":"replace",)
))"path":"/0/phones/mobile",)
))"value":"650211122222"},)
){)
))"op":"remove",)
))"path":"/1"})
]
[*
){*
))))"name":"Duke",*
))))"gender":"M",*
))))"phones":{*
)))))))"home":"650K123K4567",*
)))))))"mobile":"650211122222"}},*
)){*
))))"name":"Jane",)
))))"gender":"F",)
))))"phones":{*
)))))))"mobile":"707K555K9999"}}*
]*
))
16
19. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved.* @delabassee
JSONQP*1.1
{)
)))))"title":)"Hello!",)
)))))"author":){)
))))))))))))"familyName":)null)
))))))},)
))))))"tags":)[;"example";],)
))))))"phoneNumber":)"+012123245627890")
)})
{)
))))"title":)"Goodbye!",)
))))"author":){)
))))))))"givenName":)"John",)
))))))))"familyName":)"Doe")
)))))},)
)))))"tags":)[)"example",)"sample")],)
)))))"content":)"This)will)be)unchanged")
)})
))
{)
)))))"title":)"Hello!",)
)))))"author":){)
))))))))))))"givenName":)"John")
))))))},)
))))))"tags":)[)"example")],)
))))))"content":)"This)will)be)unchanged",)
))))))"phoneNumber":)"+01K123K456K7890")
)})
))
JSONMMerge&Patch&–&IETF&RFC&7386
20
26. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved.* @delabassee
JSONQB
• Draw*from*best*practices*of*existing*JSON*binding*implementations*
– Jackson,*Genson,*EclipseLink&MOXy,*Fleece,*JSONQlib,*Gson,*Flexjson,*JsonQio,*
JSONiJ,*Johnzon,*Xstream,*etc.*
• Switch*JSON*binding*providers*
• Implementations*compete*on*common*ground
Standard&API
27
27. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved.* @delabassee
JSONQB
// from default JsonbBuilder instance of the default JsonbProvider
Jsonb jsonb = JsonbBuilder.create();
JsonbProvider myProvider =
JsonbProvider.provider("foo.bar.ProviderImpl");
Jsonb jsonb = JsonbBuilder.newBuilder(myProvider);
// UnMarshall
Book book = jsonb.fromJson(new File("myBook.json"), Book.class);
// Marshall
String result = jsonb.toJson(myObject);
jsonb.toJson(myObject, new File(“foo.json”));
jsonb.toJson(myObject, new PrintWriter(System.out));
28