Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Pointer and JSON Patch Updates to Java API for JSON Processing Kin-man Chung.

Slides:



Advertisements
Similar presentations
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate.
Advertisements

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Your customer as a segment of one That changes every second! Hein Van Der Merwe Chief.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1.
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
MVC in JavaEE 8 Manfred Riem Principal Member of Technical Staff September, 2014 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Jim Ferrentino Elizabeth West
A Java Architecture for the Internet of Things Noel Poore, Architect Pete St. Pierre, Product Manager Java Platform Group, Internet of Things September.
Oracle Cloud Marketplace Neelesh Gurnani Director, Product Development Arif Khan Director, Product Management September 29, 2014 Copyright © 2014, Oracle.
PeopleSoft Enterprise SRM Return To Vendor
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Track the changes in your Apex application between releases: Yes you can Plsql.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle SQL Developer What’s New in Version 4.1 Jeff Smith
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Advanced Metadata Modeling Modeling for the Oracle Business Intelligence Cloud.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 2 Hidden Gems of APEX David Gale Software Engineer Oracle Application Express November,
Oracle Fusion Pioneering the Consumerization of the Enterprise
The Safe Harbor The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated.
Best Practices for Supporting Oracle Hyperion EPM and Business Intelligence Solutions Mitra Veluri Senior Principal Technical Support Engineer David Valociek.
Best Practices for Upgrading Oracle PeopleSoft Environments
American Airlines AAdvantage®:
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Amit Jha Project Leader, Product Management Oracle EBS Procurement & Contracts.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Title Slide without Picture Subtitle Presenter’s Name Presenter’s Title Organization,
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. JD Edwards Summit The Newest JDE Module – Rental Management Joel Sandberg Sales Consultant.
QAD .Net UI: New Enhancements
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. JD Edwards Summit PaaS from an Applications Perspective Charles McGuinness Director,
Click to add text © 2012 IBM Corporation 1 Streams Toolkit Landscape InfoSphere Streams Version 3.0 Mike Branson Toolkits.
Application Express 4.1 New Features Hilary Farrell, Principal Member of Technical Staff, Oracle.
1Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 Reporting from Contract.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Pointer and JSON Patch Updates to Java API for JSON Processing Kin-man Chung.
RMB Billing UX Design Concepts / Proposals Peter Picone.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. An Auto-Join Network of Things Wong, H. and Wesson, B. Oracle Confidential – Internal/Restricted/Highly.
Hadoop 2 cluster with Oracle Solaris Zones, ZFS and unified archives Orgad Kimchi - Principal Software Engineer September 29, 2014 Oracle Confidential.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 1 Quick Tutorial – Part 2 Open Data Web Services for Oracle BPM August, 2013 Forms.
1Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 Contract Management.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. JD Edwards Summit Preview the Plans for JD Edwards World A9.4 Release David Greiner,
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. JD Edwards Summit Really Cool Demo Stuff – 2015 Edition!!!!! For demo content, please.
Click to add text © 2012 IBM Corporation 1 Visualization of View Data Susan L. Cline SWS Visualization.
“This presentation is for informational purposes only and may not be incorporated into a contract or agreement.”
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Using Edition-based redefinition with PL/SQL How to deploy database code changes.
1Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
1Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Workforce Scheduling Release 5.0 for Windows Implementation Overview OWS Development Team.
Build Mobile Apps for Oracle E-Business Suite with Oracle Mobile Platform Bruce Bailey Principal Mobile/Social Solutions Consultant Jagadeesh Maira Senior.
RESTful Microservices In Java With Jersey Jakub Podlešák Software Engineer Oracle, Application Server Group September 29, 2014 Copyright © 2014, Oracle.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Planning & Budgeting Cloud Service (PBCS) Overview Business Analytics Product Group.
Click to add text © 2012 IBM Corporation 1 InfoSphere Streams Streams Console Applications InfoSphere Streams Version 3.0 Warren Acker InfoSphere Streams.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. JD Edwards Summit Recruit and Learn Solutions Extend HR into the Cloud Marie Scott.
For Oracle employees and authorized partners only. Do not distribute to third parties. © 2008 Oracle Corporation – Proprietary and Confidential.
1 of 26 For Oracle employees and authorized partners only. Do not distribute to third parties. © 2009 Oracle Corporation – Proprietary and Confidential.
Travel and Transportation General Session and Industry Excellence Awards Vijay Anand, Oracle Sundar Swaminathan, Oracle September 30, 2014 Copyright ©
-1- For Oracle employees and authorized partners only. Do not distribute to third parties. © 2009 Oracle Corporation – Proprietary and Confidential Oracle.
2 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 1.
© 2010 IBM Corporation RESTFul Service Modelling in Rational Software Architect April, 2011.
Functional Processing of Collections (Advanced) 6.0.
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | What You Need to Know About User Defined Objects (UDOs) With Tools Release 9.2.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Daddy, what's a middle wear? An incredibly oversimplified explanation of what Middleware.
My Oracle Support (The next generation Metalink experience) lynn
OpenWorld 2018 How to Combine Data from Source Sites
Charles Phillips screen
Confidential – Oracle Internal/Restricted/Highly Restricted
QAD Reporting Framework
Project Helidon Deep Dive
OpenWorld How to Prepare Data from Business Intelligence Cloud Service
OpenWorld 2018 Oracle API Platform: How to Manage Typical Workflows
Oracle Essbase: Scenario and What-If Modeling Made Simple
1.
Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be.
IXP FilterCheck A New Route Analysis Tool for IXPs
Presentation transcript:

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Pointer and JSON Patch Updates to Java API for JSON Processing Kin-man Chung Oracle Corporation September 30, 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda JSON Object Model Overview JSON Pointer JSON Patch JSON Editing/Transformation JSON Query with Java SE 8 Big JSON data

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda JSON Object Model Overview JSON Pointer JSON Patch JSON Editing/Transformation JSON Query with Java SE 8 Big JSON data

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Object Model Overview An immutable representation of a JSON value Represented by: – JsonObject – JsonArray – JsonNumber – JsonString – Literals TRUE, FALSE, and NULL 6 JsonValue

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Object Model Overview Represents a JSON object java.util.Map Created with – JsonObjectBuilder – JsonObjectReader 7 JsonObject

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Object Model Overview Represents a JSON array java.util.List Created with – JsonArrayBuilder – JsonArrayReader 8 JsonArray

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Object Model Overview Factory class for creating JSON objects Plugin factories with service provider API includes – createObjectBuilder() – createArrayBuilder() 9 Json

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |10 [ { "name": "Duke", "gender": "M", "phone": { "areacode": "650", "number": " "} }, { "name": "Jane", ”gender": "F", "phone": { "areacode": "777", "number": " "} }, { "name": "Amy", "gender": "F", "phone": { "areacode": "505" "number": " "} } ] Example: contacts in JSON

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |11 JsonArray contacts = Json.createArrayBuilder().add(Json.createObjectBuilder().add("name", "Duke").add("gender", "M").add("phone", Json.createObjectBuilder().add("areacode", "650").add("number", " "))).add(Json.createObjectBuilder().add("name", "Jane").add("gender", "F").add("phone", Json.createObjectBuilder().add("areacode", ”777").add("number": " "))).add(Json.createObjectBuilder().add("name", “Amy").add("gender", "F").add("phone", Json.createObjectBuilder().add("areacode", "505").add("number", " "))).build(); Example: contacts in JSON object model

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda JSON Object Model Overview JSON Pointer JSON Patch JSON Editing/Transformation JSON Query with Java SE 8 Big JSON data

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Pointer Specified in RFC 6901 A string syntax for referencing a JSON value Example – /0/phone/number refers to the phone number of first person in the contacts 13

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Pointer 14 Proposed API JsonArray contacts = Json.createArrayBuilder().add(…).build(); // Create a JsonPointer JsonPointer p = Json.createPointer("/0/phone/number"); // Get the value at the referenced location in the target JsonValue v = p.getValue(contacts); // Replace a value at the referenced location, returning a new array // with the change JsonArray result = p.replace(contacts, " ");

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Pointer getValue – Get the value at the referenced location add – Add/insert a value at the referenced location replace – Replace a value at the referenced location remove – Remove a value at the referenced location 15 Methods in JsonPointer

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Pointer An operation is applied to a JsonArray or JsonObject Operations do not modify the target JsonArray or JsonObject Operation add, replace, or remove returns a new JsonArray or JsonObject containing the result – Transforms the target into the result 16 Operations in JsonPointer

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda JSON Object Model Overview JSON Pointer JSON Patch JSON Editing/Transformation JSON Query with Java SE 8 Big JSON data

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Patch Specified in RFC 6902 Sequence of operations for modifying a JSON document – Operations specified in a JSON array Suitable for use in http PATCH method 18

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Patch [ {"op":"replace", "path":"/1/phone", "value": { "areacode": "111", "number": " "} } {"from":"/1/phone", "path": "/2", "op":"copy"} ] 19 Example

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Patch An patch operation is a JSON object Must have an “op” field with a value of – “add”, “replace”, “remove”, “move”, “copy”, or “test” Must have a “path” field – A JSON Pointer specifying the target location Other fields depending on “op” 20 Operations

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Patch // Create the target and the patch JsonArray target = Json.createArrayBuilder().add(…).build(); JsonArray patch = Json.createArrayBuilder()….build(); // Create JsonPatch from patch JsonPatch jsonpatch = Json.createPatch(patch); // Apply the patch to the target and return the result JsonArray result = jsonpatch.apply(target); 21 Proposed API

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda JSON Object Model Overview JSON Pointer JSON Patch JSON Editing/Transformation JSON Query with Java SE 8 Big JSON data

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Editing/Transformation A JSON Patch transforms a JSON target to a JSON result Propose adding capability to edit a JsonArray or JsonObject Use builder pattern: – Create builders with initial JsonArray or JsonObject – Add to ObjectBuilder remove(name) – Add to ArrayBuilder add(index, value), set(index, value), remove(index) – Builder returns immutable JsonArray or JsonObject when done 23

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Editing // Create the target JsonArray target = Json.createArrayBuilder().add(…).build(); // Create a builder initialized with the target JsonArrayBuilder builder = Json.createArrayBuilder(target); // Creates a new object and insert it into the array JsonObject John = Json.createObjectBuilder()….build(); JsonArray result = builder.add(1, John).build(); 24 Proposed API

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda JSON Object Model Overview JSON Pointer JSON Patch JSON Editing/Transformation JSON Query with Java SE 8 Big JSON data

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Query with Java SE 8 A JsonObject is a Map, and a JsonArray is a List, so queries can be implemented with Java’s stream operations, using Lambda expressions Example: Output names of contacts whose gender is F 26 JsonArray contacts; contacts.getValuesAs(JsonObject.class).stream().filter(x->"F".equals(x.getString("gender"))).map(x->x.getString("name")).forEach(System.out::println);

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Query with Java SE 8 Example: Collect query results in a List 27 JsonArray contacts; List names = contacts.getValuesAs(JsonObject.class).stream().filter(x->"F".equals(x.getString("gender"))).map(x->x.getString(“name”)).collect(Collectors.toList());

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Query with Java SE 8 Java Collectors return Lists or Maps. We need collectors that returns JsonArrays or JsonObjects 28 Problem

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Query with Java SE 8 New helper class JsonCollectors that construct Collectors for JSON objects or arrays toJsonArray: – Accumulates values in a JsonArray toJsonObject: – Accumulates values in a JsonObject groupBy – Implements “group by” operations on the values 29 Proposed API

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Query with Java SE 8 Collect the query result in a JsonArray 30 Example JsonArray contacts; JsonArray names = contacts.getValuesAs(JsonObject.class).stream().filter(x->"F".equals(x.getString("gender"))).map(x->x.getString("name")).collect(JsonCollectors.toJsonArray());

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Query with Java SE 8 Collect the query result in a JsonObject 31 Example JsonArray contacts; JsonObject nameToPhones = contacts.getValuesAs(JsonObject.class).stream().filter(x->"F".equals(x.getString("gender"))).collect(JsonCollectors.toJsonObject( x->x.getString("name"), x->x.getJsonObject("phone"));

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Query with Java SE 8 Group the contacts by gender 32 Example JsonArray contacts; JsonObject groups = contacts.getValuesAs(JsonObject.class).stream().collect(JsonCollectors.groupBy(x->getString("gender")));

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSON Query with Java SE 8 Change the phone areacodes from “415” to “650” 33 Example: Putting it all together Static int index = -1; JsonArray patch = contacts.getValuesAs(JsonObject.class).stream().peek(x->index++).filter(x->x.getObject("phone").getString("areacode").equals("415")).map(Json.createObjectBuilder().add("op", "replace").add("path", "/"+index+"/phone/areacode").add("value", “650”).build()).collect(JsonCollectors.toJsonArray()); JsonArray result = Json.createPatch(patch).apply(contacts);

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda JSON Object Model Overview JSON Pointer JSON Patch JSON Editing/Transformation JSON Query with Java SE 8 Big JSON data

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Support for big JSON data Big JSON data – Cannot fit in memory – Generated dynamically – Potentially infinite We already have a stream model, suitable for processing big data – Add API to make it more useful 35

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Support for big JSON data Allow creation of partial JSON data in JsonParser – Add getJsonObject() at the beginning of an object – Add getJsonArray() at the beginning of an array Allow skipping values in JsonParser API for getting java.util.stream in JsonParser – Lazy evaluation, pull model – Low level: Stream of parse events – High level: Stream of JsonObject and JsonArray elements Performance matters 36

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Summary Support for JSON Pointer and JSON Patch Add editing/transformation to JsonObject and JsonArray Add help class/method for JSON query Add support for big JSON data WARNING: The API changes are just proposals, are not final 37

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Q & A 38

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |39