Java String Decode decode(String s)

Here you can find the source of decode(String s)

Description

Obtain a JsonStructure from a String.

License

Apache License

Parameter

Parameter Description
s String <p>

Return

JsonStructure

Declaration

public static JsonStructure decode(String s) 

Method Source Code


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

import java.io.StringReader;

import java.util.Objects;

import javax.json.Json;

import javax.json.JsonReader;

import javax.json.JsonStructure;

public class Main {
    /**/* w  ww .j ava 2 s . c  om*/
     * Obtain a {@link JsonStructure} from a String.
     * <p>
     * @param s String
     * <p>
     * @return JsonStructure
     */
    public static JsonStructure decode(String s) {
        if (s == null || s.isEmpty()) {
            return null;
        }
        final StringReader r = new StringReader(Objects.requireNonNull(s));
        try (JsonReader jr = Json.createReader(r)) {
            return jr.read();
        }
    }
}

Related

  1. decode(String bytes)
  2. decode(String cipherText)
  3. decode(String in)
  4. decode(String name)
  5. decode(String s)
  6. decode(String s)
  7. decode(String s)
  8. decode(String s)