Read data from YAML and Json using Java

In the automation frameworks whether its TestNG/Cucumber based we need to get Test data in order to parameterise.

Here is the simple ways to read data from YAML and Json using Jackson lib in Java.

Use the following libraries :

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.3.0</version>
</dependency>

Check out the following code where tries to read ‘Students.json’/’Students.YAML’ using Object Mapper.

Hope this helps. :)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response