Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.JSONArray;
import org.json.JSONObject;

public class Main {
    private static final ObjectMapper mapper = new ObjectMapper();

    public static String asJson(Object value) throws Exception {
        if (value instanceof JSONArray || value instanceof JSONObject) {
            return value.toString();
        }

        return mapper.writeValueAsString(value);
    }
}