Writing JSON Object as Object not as String to File

Writing JSON Object as Object not as String to File

I want to write a JSON Object to a file.Currently I have tried using ObjectMapper and Gson but they are writing the JSON as JSONString, Thus the output file has JSON string rather than object. So is there a way JSON Object is written as Object rather than String

I want to write a JSON Object to a file.Currently I have tried using ObjectMapper and Gson but they are writing the JSON as JSONString, Thus the output file has JSON string rather than object. So is there a way JSON Object is written as Object rather than String

JSONObject responseData = new JSONObject(response.getBody().toString());
org.json.simple.JSONObject object  = new
org.json.simple.JSONObject(responseData.toMap());
ObjectMapper objMapper = new ObjectMapper();
objMapper.writeValue(new File(path) , object);

Now the above code is writing the JSON Object as String in to file not a JSONObject.

java json

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

Java Core (2020) | Java for beginners | Brush up your Java Skills | Get Hired

In this video we will learn about all the major concepts that come under Java Core . The course is very carefully designed and is made with keeping simplicit...

Introduction to JSON - Java

Learn the fundamentals of parsing and manipulating JSON data with the JSON-Java library.

Jackson 2 – Convert Java Object to / from JSON

Learn how to use Jackson 2 library to convert JSON to Java Object and convert Java Object to JSON. Learn how to convert Java Object to or from JSON using Jackson 2 with an example.

Convert JSON Into Java Object using JackSon Library

Learn to Convert JSON String Into Java Object Using JackSon library. Learn how to convert JSON to Java Object and Java Object to JSON in Java using Jackson API.

How to Convert a Java Object into a JSON String

In this article, you'll learn how to convert a Java Object into a JSON String