当前位置: 首页>>代码示例>>Java>>正文


Java JsonString类代码示例

本文整理汇总了Java中javax.json.JsonString的典型用法代码示例。如果您正苦于以下问题:Java JsonString类的具体用法?Java JsonString怎么用?Java JsonString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JsonString类属于javax.json包,在下文中一共展示了JsonString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyInjectedAudience

import javax.json.JsonString; //导入依赖的package包/类
@GET
@Path("/verifyInjectedAudience")
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("Tester")
public JsonObject verifyInjectedAudience(@QueryParam("aud") String audience) {
    boolean pass = false;
    String msg;
    // aud
    List<JsonString> audValue = aud.getValuesAs(JsonString.class);
    if(audValue == null || audValue.size() == 0) {
        msg = Claims.aud.name()+"value is null or empty, FAIL";
    }
    else if(audValue.get(0).getString().equals(audience)) {
        msg = Claims.aud.name()+" PASS";
        pass = true;
    }
    else {
        msg = String.format("%s: %s != %s", Claims.aud.name(), audValue, audience);
    }
    JsonObject result = Json.createObjectBuilder()
        .add("pass", pass)
        .add("msg", msg)
        .build();
    return result;
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:26,代码来源:JsonValuejectionEndpoint.java

示例2: isStatusOk

import javax.json.JsonString; //导入依赖的package包/类
/**
    * Says if status is OK
    * @return true if status is OK
    */
   public boolean isStatusOk() {

if (jsonResult == null || jsonResult.isEmpty()) {
    return false;
}

try {
    JsonReader reader = Json.createReader(new StringReader(jsonResult));
    JsonStructure jsonst = reader.read();

    JsonObject object = (JsonObject) jsonst;
    JsonString status = (JsonString) object.get("status");

    if (status != null && status.getString().equals("OK")) {
	return true;
    } else {
	return false;
    }
} catch (Exception e) {
    this.parseException = e;
    invalidJsonStream = true;
    return false;
}

   }
 
开发者ID:kawansoft,项目名称:aceql-http,代码行数:30,代码来源:ResultAnalyzer.java

示例3: readAdapterNotes

import javax.json.JsonString; //导入依赖的package包/类
private static String readAdapterNotes(JsonObject root) {
    if (root.containsKey("adapterNotes")) {
        JsonValue notes = root.get("adapterNotes");
        if (notes.getValueType() == ValueType.STRING) {
            // Return unquoted string
            return ((JsonString)notes).getString();
        } else {
            return notes.toString();
        }
    }
    return "";
}
 
开发者ID:EXASOL,项目名称:virtual-schemas,代码行数:13,代码来源:RequestJsonParser.java

示例4: send

import javax.json.JsonString; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * @since 2017/12/13
 */
@Override
public RemoteResult send(RemoteRequest __r)
	throws NullPointerException, RemoteException
{
	if (__r == null)
		throw new NullPointerException();
	
	// Send the request to the consumer so that it may test the remote
	// end accordingly
	Consumer<RemoteRequest> function = this.function;
	if (function != null)
		function.accept(__r);
	
	// Check the authorization token
	if (MockConfiguration.VALID_TOKEN.equals(((JsonString)
		((JsonObject)__r.bodyValue()).get("client_id")).getString()))
		return new RemoteResult(202, "Accepted");
	return new RemoteResult(401,
		"{\"message\":\"Invalid client id sent.\"}");
}
 
开发者ID:iopipe,项目名称:iopipe-java-core,代码行数:25,代码来源:MockConnection.java

示例5: toJavaObject

import javax.json.JsonString; //导入依赖的package包/类
/**
 * Converts a {@link JsonValue} to its corresponding Java object. Values of type {@link
 * JsonObject} or {@link JsonArray} are converted as specified by {@link #toJavaMap} and {@link
 * #toJavaList}, respectively.
 */
@Nullable
public static Object toJavaObject(JsonValue value) {
  switch (value.getValueType()) {
    case ARRAY:
      return toJavaList((JsonArray) value);
    case FALSE:
      return Boolean.FALSE;
    case NULL:
      return null;
    case NUMBER:
      JsonNumber number = (JsonNumber) value;
      return number.isIntegral() ? number.intValue() : number.doubleValue();
    case OBJECT:
      return toJavaMap((JsonObject) value);
    case STRING:
      return ((JsonString) value).getString();
    case TRUE:
      return Boolean.TRUE;
    default:
      throw new VerifyException("Json value with unknown type: " + value);
  }
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:28,代码来源:JavaxJson.java

示例6: unbox

import javax.json.JsonString; //导入依赖的package包/类
public static Object unbox(JsonValue value, Function<JsonStructure, Object> convert) throws JsonException {
    switch (value.getValueType()) {
        case ARRAY:
        case OBJECT:
            return convert.apply((JsonStructure) value);
        case FALSE:
            return Boolean.FALSE;
        case TRUE:
            return Boolean.TRUE;
        case NULL:
            return null;
        case NUMBER:
            JsonNumber number = (JsonNumber) value;
            return number.isIntegral() ? number.longValue() : number.doubleValue();
        case STRING:
            return ((JsonString) value).getString();
        default:
            throw new JsonException("Unknow value type");
    }
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:21,代码来源:JsonUtil.java

示例7: createShibGroup

import javax.json.JsonString; //导入依赖的package包/类
@POST
@Path("shib")
public Response createShibGroup(JsonObject shibGroupInput) {
    String expectedNameKey = "name";
    JsonString name = shibGroupInput.getJsonString(expectedNameKey);
    if (name == null) {
        return errorResponse(Response.Status.BAD_REQUEST, "required field missing: " + expectedNameKey);
    }
    String expectedAttributeKey = "attribute";
    JsonString attribute = shibGroupInput.getJsonString(expectedAttributeKey);
    if (attribute == null) {
        return errorResponse(Response.Status.BAD_REQUEST, "required field missing: " + expectedAttributeKey);
    }
    String expectedPatternKey = "pattern";
    JsonString pattern = shibGroupInput.getJsonString(expectedPatternKey);
    if (pattern == null) {
        return errorResponse(Response.Status.BAD_REQUEST, "required field missing: " + expectedPatternKey);
    }
    ShibGroup shibGroupToPersist = new ShibGroup(name.getString(), attribute.getString(), pattern.getString(), shibGroupPrv);
    ShibGroup persitedShibGroup = shibGroupPrv.persist(shibGroupToPersist);
    if (persitedShibGroup != null) {
        return okResponse("Shibboleth group persisted: " + persitedShibGroup);
    } else {
        return errorResponse(Response.Status.BAD_REQUEST, "Could not persist Shibboleth group");
    }
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:27,代码来源:Groups.java

示例8: Product

import javax.json.JsonString; //导入依赖的package包/类
/**
 * Constructor
 *
 * @param data Json load from response body
 */
Product(JsonObject data) {
    super(data);

    this.imageList = new LinkedList<>();

    if (data.get("Images") instanceof JsonObject) {
        JsonValue imageData = data.getJsonObject("Images").get("Image");
        if (imageData instanceof JsonArray) {
            for (JsonValue img : (JsonArray) imageData) {
                if (img instanceof JsonString) {
                    imageList.add(((JsonString) img).getString());
                }
            }
        } else {
            imageList.add(imageData.toString());
        }
    }
    this.productData = new ProductData(data.getJsonObject("ProductData"));
}
 
开发者ID:rocket-internet-berlin,项目名称:SellerCenterSDK-Java,代码行数:25,代码来源:Product.java

示例9: mapJsonToSession

import javax.json.JsonString; //导入依赖的package包/类
public static Session mapJsonToSession(JsonObject jsonObject) {
    int capacity = jsonObject.containsKey("capacity") ? jsonObject.getInt("capacity") : 0;
    long endTime = jsonObject.containsKey("endTime") ? jsonObject.getJsonNumber("endTime").longValue() : 0L;
    String experienceLevel = jsonObject.containsKey("experienceLevel") ? jsonObject.getString("experienceLevel") : "";
    String location = jsonObject.containsKey("location") ? jsonObject.getString("location") : "";
    int registered = jsonObject.containsKey("registered") ? jsonObject.getInt("registered") : 0;
    List<String> speakersUuid = new ArrayList<>();
    if (jsonObject.containsKey("speakersUuid")) {
        JsonObject speakersObject = jsonObject.getJsonObject("speakersUuid");
        for (JsonString jsonString : speakersObject.getJsonArray("items").getValuesAs(JsonString.class)) {
            speakersUuid.add(jsonString.getString());
        }
    }
    long startTime = jsonObject.containsKey("startTime") ? jsonObject.getJsonNumber("startTime").longValue() : 0L;
    String summary = jsonObject.containsKey("summary") ? jsonObject.getString("summary") : "";
    String title = jsonObject.containsKey("title") ? jsonObject.getString("title") : "";
    Track track = jsonObject.containsKey("track") ? Track.valueOf(jsonObject.getString("track")) : null;
    String type = jsonObject.containsKey("type") ? jsonObject.getString("type") : "";
    String uuid = jsonObject.containsKey("uuid") ? jsonObject.getString("uuid") : "";
    return new Session(uuid, title, summary, location, capacity, registered, startTime, endTime,
            track, type, experienceLevel, speakersUuid);
}
 
开发者ID:gluonhq,项目名称:javaone2016,代码行数:23,代码来源:ServiceUtils.java

示例10: buildAdditionalQuery

import javax.json.JsonString; //导入依赖的package包/类
public Bson buildAdditionalQuery(JsonObject filter) {		
	List<Bson> fragments = new ArrayList<>();
	if(filter.containsKey("eid")) {
		fragments.add(new Document("executionID", filter.getString("eid")));
	}
	
	fragments.add(or(new Document("_class","step.artefacts.reports.CallFunctionReportNode"),
			new Document("_class","step.artefacts.reports.EchoReportNode"),
			new Document("error.root",true)));
	if(filter.containsKey("testcases")) {
		//customAttributes.TestCase
		List<String> testcaseIds = new ArrayList<>();
		filter.getJsonArray("testcases").forEach(v->testcaseIds.add(((JsonString)v).getString()));
		fragments.add(in("customAttributes.TestCase",testcaseIds));
	}
	
	return and(fragments);
}
 
开发者ID:denkbar,项目名称:step,代码行数:19,代码来源:LeafReportNodesFilter.java

示例11: onMessage

import javax.json.JsonString; //导入依赖的package包/类
@OnMessage
public void onMessage(String id, Session s) throws IOException {
	JsonObject m = manager.get(id);
	if (m == null) {
		s.close();
		return;
	}

	JsonString url = m.getJsonString("meetingURL");

	if (url != null) {
		s.getBasicRemote().sendText(url.getString());
		s.close();
		return;
	}

	Queue<Session> sessions = listeners.get(id);
	if (sessions == null) {
		sessions = new ArrayBlockingQueue<>(1000);
		Queue<Session> actual = listeners.putIfAbsent(id, sessions);
		if (actual != null) {
			sessions = actual;
		}
	}
	sessions.add(s);
}
 
开发者ID:WASdev,项目名称:sample.microprofile.meetingapp,代码行数:27,代码来源:MeetingNotifier.java

示例12: fromJSON

import javax.json.JsonString; //导入依赖的package包/类
public static CouchID fromJSON(InputStream is) {
    JsonReader rdr = null;
    try {
        rdr = Json.createReader(is);
        JsonObject couchIDJson = rdr.readObject();

        JsonString idJson = couchIDJson.getJsonString("id");
        JsonString revJson = couchIDJson.getJsonString("rev");
        CouchID attendee = new CouchID(idJson.getString(), revJson.getString());
        return attendee;
    } finally {
        if (rdr != null) {
            rdr.close();
        }
    }

}
 
开发者ID:eclipse,项目名称:microprofile-conference,代码行数:18,代码来源:CouchID.java

示例13: duplication

import javax.json.JsonString; //导入依赖的package包/类
@Test
public void duplication() {
	String json = "[\"club\", \"diamond\", \"club\", \"spade\"]";
	Schema schema = schema(array(string()).unique());
	JsonValidator validator = new BasicJsonValidator(schema);
	ValidationResult result = validator.validate(new StringReader(json));

	assertResultValid(result, json);
	assertThat(result.getProblems().size(), equalTo(1));
	assertThat(result.getProblems().get(0), instanceOf(ArrayDuplicateItemProblem.class));
	ArrayDuplicateItemProblem p = (ArrayDuplicateItemProblem)result.getProblems().get(0);
	assertThat(p.getPointer().toString(), equalTo(""));
	assertThat(p.getDuplicateIndex(), equalTo(2));
	assertThat(((JsonString)p.getDuplicateItem()).getString(), equalTo("club"));
	assertNotNull(p.getDescription());
}
 
开发者ID:i49,项目名称:hibiscus,代码行数:17,代码来源:ArrayValidationTest.java

示例14: botInChannel

import javax.json.JsonString; //导入依赖的package包/类
private boolean botInChannel(final String team, final String channel) {
    final String bot = botUser(team);
    final String botToken = utoken(bot);
    try {
        return channelInfo(botToken, channel).get()
                .getJsonObject("channel")
                .getJsonArray("members")
                .stream()
                .map(jv -> ((JsonString) jv).getString())
                .filter(bot::equals)
                .findAny()
                .isPresent();
    } catch (final Exception x) {
        return false;
    }
}
 
开发者ID:aztecrex,项目名称:java-translatebot,代码行数:17,代码来源:CommandHandler.java

示例15: plainifyJsonValue

import javax.json.JsonString; //导入依赖的package包/类
private Object plainifyJsonValue(final JsonValue jval) {
    switch (jval.getValueType()) {
    case ARRAY:
        return plainifyJsonArray((JsonArray) jval);
    case FALSE:
        return Boolean.FALSE;
    case TRUE:
        return Boolean.TRUE;
    case NULL:
        return null;
    case NUMBER:
        return ((JsonNumber) jval).bigDecimalValue();
    case OBJECT:
        return plainifyJsonObject((JsonObject) jval);
    case STRING:
        return ((JsonString) jval).getString();
    default:
        throw new RuntimeException("unexpected json type");
    }
}
 
开发者ID:aztecrex,项目名称:java-translatebot,代码行数:21,代码来源:OauthHandler.java


注:本文中的javax.json.JsonString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。