Convert a java map to JSON using Jackson

In this post we will convert a java map to JSON using the jackson library. Setup: You will need to add the following dependancy to your project

Convert a java map to JSON: The following example shows how to convert a Java map to JSON using the ObjectMapper class. The ObjectMapper class has a … Continue reading Convert a java map to JSON using Jackson

Convert a JSON array to a List using Jackson

In this post we will provide an example of how to convert a JSON array to a List using Jackson. Setup: In this example you will need to add the following dependancy

Convert a JSON array to a list: The example below shows how to convert a JSON array to a java list using … Continue reading Convert a JSON array to a List using Jackson

Convert a List to JSON array using Jackson

In this post we will show how to convert a List to JSON array using Jackson. Setup: In this example you will need to add the following dependancy

Convert a List to JSON array: The example below shows how to convert a java list to a JSON array using the Jackson parser.

As … Continue reading Convert a List to JSON array using Jackson

How to convert a Java object to JSON using Jackson

In this post we will provide an example on how to convert a Java object to JSON using Jackson. Setup: You will need to add the following dependancy to your project.

How to convert a java object to JSON using Jackson: The following example uses the User and Address classes:

 

Continue reading How to convert a Java object to JSON using Jackson

How to parse a JSON string to a Java object using Jackson

In this post we will provide an example on how to parse a JSON string to a Java object using Jackson. Setup: You will need to include the following maven dependancy into your project.

How to parse a JSON string to a Java object using Jackson: The following example shows how to convert a … Continue reading How to parse a JSON string to a Java object using Jackson

How to get your server IP address using Java

In this post we will show how to get your server IP address using Java. How to get server IP address The example below shows how to get the host server IP address.

The getLocalHost() method will return information about the host machine, calling¬†getHostAddress() will give you the IP address.¬†Running the above code produces … Continue reading How to get your server IP address using Java

Convert a String to a List split by new line

In this post we will show how to convert a string to a List by splitting the string based on new lines and vice versa. Convert a String to a List The following example will convert a string to a list split by new line.

We have split the string using the split() method … Continue reading Convert a String to a List split by new line