JSON-P 1.1 Public Review Starts Now!

Navigate the Maze of the End-User Experience and pick up this APM Essential guide, brought to you in partnership with CA Technologies
The JSON-P 1.1 (Java API for JSON Processing) specification has just posted a public review (this is the last step before the proposed final specification). For those unaware, JSON-P is a lower level JSON processing API introduced as part of Java EE 7. JSON-P 1.1 is a relatively more minor but important update that will be included in Java EE 8. Java EE 8 will also include a higher level declarative JSON binding API named JSON-B. While JSON binding is clearly important, there are many cases where a simple processing API is more appropriate. JSON-B also depends on JSON-P under the hood.
These two APIs together are extremely important in making JSON a first-class citizen of the standard Java platform, just like JAXP (Java API for XML Processing) and JAXB (Java API for XML Binding) did many years ago for XML. With these two APIs in place, Java developers can simply think of JSON as yet another Java serialization format. No more third-party libraries and no more configuration - things will simply work out of the box when it comes to processing JSON. In my view, these APIs are so critical they should indeed be moved to a modular Java SE release, much like JAXB and JAXP are already a part of Java SE.
The changes introduced in JSON-P 1.1 mostly includes staying up-to-date with JSON open standards like JSON Pointer and JSON Patch. There is also some Java SE 8 alignment work included in JSON-P 1.1. A very good resource for an introduction is a slide deck from specification lead Dmitry Kornilov as well as Werner Keil from the community presented at Java2Days 2016 (click here if you can't see the embedded slide deck).
You can download and take a look at the draft specification from the JCP site. You should do your part demonstrating first hand that JSON-P 1.1 is a critical standard for Java — by engaging actively. Here are the many ways you can engage (most of this comes directly from the Adopt-a-JSR page I drafted while still at Oracle):
  • You can still join the specification itself as an expert or a contributor. You can do that via the JCP page for the specification.
  • You can have your JUG officially support the standard through Adopt-a-JSR.
  • You can simply join the discussion without any ceremony by subscribing to the JSON-P 1.1 specification user alias.
  • You can share ideas and feedback, possibly by entering issues in the public issue tracker.
  • You can read the public review specification now.
  • You can try out the reference implementation now.
  • You can write or speak about JSON-P 1.1 now.
  • You can encourage others to participate.
The next step is up to you. You can be a real part of Java's ongoing success yourself instead of simply being a passive consumer. If you have any questions I am happy to try to help — just drop me a note anytime.
Thrive in the application economy with an APM model that is strategic. Be E.P.I.C. with CA APM.  Brought to you in partnership with CA Technologies.
Topics:
 
JAVA EE ,JAVA ,JAVA API ,JSON
 
 Comment (0)
 
Save
 
 582 Views
Published at DZone with permission of Reza Rahman, DZone MVBSee the original article here.
Opinions expressed by DZone contributors are their own.

Which For Loop?

There are three types of for loops out there—for loops, for-each loops, and Java 8's lambda-friendly for-each loops. See which you should use—and when.

  · Java Zone
 
 Comment (1)
 
Save
 
 1,944 Views
What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.
Java 8 introduced another type of for loop. This gave us the third way to use them. You would think that releasing another way to use the loop would suggest that it must be better than the others. But that is not the case. Each one has subtle differences, meaning you should have a little think before you decide which one to use.
Types of for loops:
  • Normal for loop
  • For-each loop
  • Java 8 for-each loop

Normal For Loop

Now I’m just going to come straight out and say this: These loops look ugly and I try to stay away from them as much as possible. Anyway, now that I have said that, let's get back to explaining what they are. This type of loop uses a counter to iterate through the elements of a list or array. The easiest way to explain it is through an example.
List<Integer> list = Arrays.asList(1,2,3,4,5,6);
for(int index=0; index<list.size(); index++) {
    System.out.println("I have read the number: " + list.get(index));
}
int[] array = new int[]{ 1,2,3,4,5,6};
for(int index=0; index<array.length; index++) {
    System.out.println("I have read the number: " + array[index]);
}

The above shows how to iterate through both a list and an array. It does so by increasing the counters value index and retrieving the element at that position using list.get(index) or array[index]. After it has the element it can do whatever it wants with it.
The advantage of using this type of loop is that you have more control over how you read the elements than you do with the other types of loops. If you wanted, you could retrieve the element at position index-1 very easily. Just remember to handle the scenario of index = 0, or you're going to have an IndexOutOfBoundsException on your hands. This advantage of control is also its downside, as you need to manually retrieve the elements, which makes the code look cluttered. The ugliness of this loop is not found in the other types of loops.

The For-Each Loop

The name of this loop pretty much sums up what it does. For each element in the collection or array, do something with it. The is no need to increment through the list using a counter as that is all done behind the scenes. Simply give the object you want to retrieve and type and name and you are good to go.
List<Integer> list = Arrays.asList(1,2,3,4,5,6);
for(int number : list) {
    System.out.println("I have read the number:" + number);
}
int[] array = new int[]{ 1,2,3,4,5,6};
for(int number : array) {
    System.out.println("I have read the number: " + number);
}
Set<Integer> set = new HashSet<>(Arrays.asList(1,2,3,4,5,6));
for(int number : set) {
    System.out.println("I have read the number: " + number);
}

Look how simple and pretty they are, so much nicer than those ugly loops above. Anyway, the loops will go through the elements and, during each iteration, provide the defined variable a value from the collection or array. The order in which the values are retrieved follows the same order that the elements have in the collection or array. Another advantage of the for-each loop is that it can iterate through the elements of a Set, as it does not have its own get() method.

The Java 8 For-Each Loop

This is the new for loop that has been added with the release of Java 8. It has all the characteristics of the normal for-each loop but uses lambda expressions to define what it does with each element it iterates over from the collection, although this form cannot be used on an array. The example below is pretty self-explanatory.
List<Integer> list = Arrays.asList(1,2,3,4,5,6);
list.forEach(number -> System.out.println("I have read the number:" + number));

This form of for loop can be used instead of the normal for-each loop, as, functionally, they are the same, but the syntax is different. This form looks nicer for simple lambda expressions and can allow a loop to be defined in a single line if the expression is small enough. When it comes to loops with more statements inside them, it is the user's preference which for-each loop they use, as the benefit of decreasing the amount of code written is no longer there.
So which loop should you use? If you need total control over the elements you read or need to add and remove elements from the list, then a normal for loop is the way to go. If you simply need to perform some statements on elements of the list and don’t need to add or remove elements, then both the normal for-each and Java 8 for-each loops will suffice. Determining which for-each loop to use is up to you. Personally, for singular or such smaller statements, I would use the Java 8 for-each loop, but for loops with longer statements inside, then the good old normal for-each will be my loop of choice.
P.C: https://dzone.com/articles/json-p-11-public-review-starts-now?utm_medium=feed&amp;utm_source=feedpress.me&amp;utm_campaign=Feed:%20dzone

No comments

Powered by Blogger.