Java Is Json isValidJSON(final String json)

Here you can find the source of isValidJSON(final String json)

Description

is Valid JSON

License

Apache License

Declaration

public static boolean isValidJSON(final String json) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;

public class Main {
    public static boolean isValidJSON(final String json) {
        boolean valid = false;

        try {/*  w w  w .ja v a2s. co m*/
            ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.readTree(json);
        } catch (IOException e) {
            valid = false;
        }
        return valid;
    }
}

Related

  1. isJSONValid(String jsonInString)
  2. isJSONValid(final String json)
  3. isJSONEqual(M expectedJSON, N actualJSON)
  4. isValidJSON(final String json)
  5. isValidJSON(final String json)