Here you can find the source of createJsonValue(String string)
Parameter | Description |
---|---|
string | the String |
public static JsonValue createJsonValue(String string)
//package com.java2s; /*//ww w .j a v a 2 s . com * Copyright 2015-2017 Richard Linsdale. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import javax.json.Json; import javax.json.JsonValue; public class Main { /** * Create a JsonValue using a String * * @param string the String * @return the equivalent JsonValue */ public static JsonValue createJsonValue(String string) { return Json.createObjectBuilder().add("value", string).build().getJsonString("value"); } /** * Create a JsonValue using an integer * * @param value the integer value * @return the equivalent JsonValue */ public static JsonValue createJsonValue(int value) { return Json.createObjectBuilder().add("value", value).build().getJsonNumber("value"); } }