The javax.json.JsonObject interface can represent an immutable JSON object value and provides an unmodifiable map view to the JSON object name/value mappings. A JsonObject instance can be created from an input source using the static method readObject() of javax.json.JsonReader class and also can be created using the static method createObjectBuilder() of javax.json.Json class.Syntaxpublic static JsonObjectBuilder createObjectBuilder()Exampleimport java.io.*; import javax.json.*; public class JsonObjectTest { public static void main(String[] args) throws Exception { JsonObjectBuilder builder = Json.createObjectBuilder(); builder.add("Name", "Adithya"); builder.add("Designation", "Python Developer"); builder.add("Company", "TutorialsPoint"); builder.add("Location", "Hyderabad"); JsonObject data = builder.build(); ... Read More
An IP address stands for Internet Protocol Address. Devices are assigned with specified IP Address to identify the device which are connected on internet. Public IP addresses are routable on Internet and are generally provided by an ISP (Internet service provider) which are accessible over the Internet.Do you know how to find public IP address from Linux command line? There are several ways to find and identify public IP address. For example, we can use third party websites or “shell” commands. This article provides simple methods to find public IP address from command line on Linux.Who Uses Public IP Addresses?Public ... Read More
Linux process can be visualized as a running instance of a program where each thread in the Linux is nothing but a flow of execution of the processes. Do you know how to see the number of threads per process on Linux environment? There are several ways to count the number of threads. This article deals with, how to read the information about processes on Linux and also to count the number of threads per process.Read Process InformationTo read the process information use ‘ps’ command. This command is used to read a snapshot of the current processes on Linux. However, ... Read More
The javax.json.JsonArray interface can represent an immutable JSON array and provides an unmodifiable list view of the values in the array. A JsonArray object can be created by reading JSON data from an input source and also using a static method createArrayBuilder() of javax.json.Json class. We need to import the javax.json package (download javax.json-api.jar file) in order to execute it.Syntaxpublic static JsonArrayBuilder createArrayBuilder()Exampleimport java.io.*; import javax.json.*; import javax.json.JsonObjectBuilder; public class JsonArrayTest { public static void main(String[] args) { JsonObjectBuilder builder = Json.createObjectBuilder(); builder.add("Name", "Raja Ramesh"); builder.add("Designation", "Java Developer"); builder.add("Company", "TutorialsPoint"); ... Read More
The world is now embracing connectivity and communication like never before through the application of various mobility based devices. Mobile computing devices such as mobile phones, palmtops etc. have become a part of our daily routine as they are convenient and effective to use.Mobile IP (Internet Protocol) serves the needs of the burgeoning population of mobile computer users who wish to connect to the Internet and maintain communications as they move from place to place.Mobile IP (or MIP) is an Internet Engineering Task Force (IETF) standard communications protocol that is designed to allow mobile device users to move from one network ... Read More
The Flexjson is a lightweight library for serializing and deserializing Java objects into and from JSON format. We can deserialize a Java object from a Reader stream using the deserialize() method of JSONDeserializer class, it uses an instance of Reader class as JSON input.Syntaxpublic T deserialize(Reader input)Exampleimport java.io.*; import flexjson.JSONDeserializer; public class JSONDeserializeReaderTest { public static void main(String[] args) { JSONDeserializer deserializer = new JSONDeserializer(); String jsonStr = "{" + "\"firstName\": \"Adithya\", " + ... Read More
Looking to explore the world of online programming? then, there is good news to all of you!! Currently, there are few online programming websites which offer free services. Tutorialspoint is one such provider. Few years back, Tutorialspoint.com started compiler online service and based on the excellent response, the company has enhanced the service which is renamed as “Coding Ground”. It is a one stop solution for aspiring programmers and IT professionals to start coding in their relevant software without any installation requirement.The biggest technology innovators like Google, Microsoft or Amazon were built due to the consistent effort of programmers as ... Read More
A JSONObject is an unordered collection of a name and value pairs. A few important methods of JSONArray are accumulate(), put(), opt(), append(), write() and etc. The accumulate() method accumulates the values under a key and this method similar to the put() method except if there is an existing object stored under a key then a JSONArray can be stored under a key to hold all of the accumulated values. If there is an existing JSONArray then a new value can be added.Syntaxpublic JSONObject accumulate(java.lang.String key, java.lang.Object value) throws JSONExceptionExampleimport org.json.*; public class JSONAccumulateMethodTest { public static void main(String[] args) throws JSONException { ... Read More
A JSONObject can parse the text from String to produce a Map kind of an object. An Enum can be used to define a collection of constants, when we need a predefined list of values which do not represent some kind of numeric or textual data then we can use an enum. We can convert a JSON object to an enum using the readValue() method of ObjectMapper class.In the below example, we can convert/deserialize a JSON object to Java enum using the Jackson library.Exampleimport com.fasterxml.jackson.databind.*; public class JSONToEnumTest { public static void main(String arg[]) throws Exception { ObjectMapper mapper ... Read More
The Jackson @JsonInclude annotation can be used to exclude the properties or fields of a class under certain conditions and it can be defined using the JsonInclude.Include enum. The JsonInclude.Include enum contains few constants like "ALWAYS", "NON_DEFAULT", "NON_EMPTY" and "NON_NULL" to determine whether to exclude the property(field) or not.Syntaxpublic static enum JsonInclude.Include extends EnumExampleimport com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.*; import java.io.*; public class JsonIncludeTest { public static void main(String args[]) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); Employee emp = new Employee(); String jsonString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(emp); System.out.println(jsonString); } } // Employee class ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP