Package net.minidev.json

Examples of net.minidev.json.JSONObject.toJSONString()


    JSONObject jsonObject = new JSONObject();
    jsonObject.put("error", "access_denied");
    jsonObject.put("error_description", "Access denied");
    jsonObject.put("error_uri", "https://c2id.com/errors/access_denied");

    httpResponse.setContent(jsonObject.toJSONString());

    ErrorObject errorObject = ErrorObject.parse(httpResponse);

    assertEquals(403, errorObject.getHTTPStatusCode());
    assertEquals("access_denied", errorObject.getCode());
View Full Code Here


    httpResponse.setContentType(CommonContentTypes.APPLICATION_JSON);
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("error", "access_denied");
    jsonObject.put("error_description", "Access denied");

    httpResponse.setContent(jsonObject.toJSONString());

    ErrorObject errorObject = ErrorObject.parse(httpResponse);

    assertEquals(403, errorObject.getHTTPStatusCode());
    assertEquals("access_denied", errorObject.getCode());
View Full Code Here

    HTTPResponse httpResponse = new HTTPResponse(403);
    httpResponse.setContentType(CommonContentTypes.APPLICATION_JSON);
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("error", "access_denied");

    httpResponse.setContent(jsonObject.toJSONString());

    ErrorObject errorObject = ErrorObject.parse(httpResponse);

    assertEquals(403, errorObject.getHTTPStatusCode());
    assertEquals("access_denied", errorObject.getCode());
View Full Code Here

    throws Exception {

    JSONObject o = new JSONObject();
    o.put("fruit", Arrays.asList("apples", "pears", "plums"));

    String json = o.toJSONString();

    List<String> fruit = JSONObjectUtils.getStringList(JSONObjectUtils.parseJSONObject(json), "fruit");

    assertEquals("apples", fruit.get(0));
    assertEquals("pears", fruit.get(1));
View Full Code Here

    throws Exception {

    JSONObject o = new JSONObject();
    o.put("fruit", Arrays.asList("apples", "pears", "plums"));

    String json = o.toJSONString();

    Set<String> fruit = JSONObjectUtils.getStringSet(JSONObjectUtils.parseJSONObject(json), "fruit");

    assertTrue(fruit.contains("apples"));
    assertTrue(fruit.contains("pears"));
View Full Code Here

    throws Exception {

    JSONObject o = new JSONObject();
    o.put("fruit", Arrays.asList("apples", 10, true));

    String json = o.toJSONString();

    o = JSONObjectUtils.parseJSONObject(json);

    try {
      JSONObjectUtils.getStringSet(o, "fruit");
View Full Code Here

    assertEquals("https://example.com/in", ((List<String>)o.get("redirect_uris")).get(0));
    assertEquals("secret", (String)o.get("client_secret"));
    assertEquals(0l, ((Long)o.get("client_secret_expires_at")).longValue());
    assertEquals(4, o.size());

    String jsonString = o.toJSONString();

    o = com.nimbusds.jose.util.JSONObjectUtils.parseJSONObject(jsonString);

    clientInfo = ClientInformation.parse(o);
View Full Code Here

    o.put("client_name", "Test App");
    o.put("grant_types", Arrays.asList("client_credentials"));
    o.put("response_types", new ArrayList<String>());
    o.put("scope", "read write");

    String json = o.toJSONString();

    ClientMetadata metadata = ClientMetadata.parse(JSONObjectUtils.parseJSONObject(json));

    assertEquals("Test App", metadata.getName());
    assertTrue(metadata.getGrantTypes().contains(GrantType.CLIENT_CREDENTIALS));
View Full Code Here

    o.put("client_name", "Test App");
    o.put("grant_types", Arrays.asList("password"));
    o.put("response_types", new ArrayList<String>());
    o.put("scope", "read write");

    String json = o.toJSONString();

    ClientMetadata metadata = ClientMetadata.parse(JSONObjectUtils.parseJSONObject(json));

    assertEquals("Test App", metadata.getName());
    assertTrue(metadata.getGrantTypes().contains(GrantType.PASSWORD));
View Full Code Here

    o.put("client_name", "Test App");
    o.put("grant_types", new ArrayList<String>());
    o.put("response_types", new ArrayList<String>());
    o.put("scope", "read write");

    String json = o.toJSONString();

    ClientMetadata metadata = ClientMetadata.parse(JSONObjectUtils.parseJSONObject(json));

    assertEquals("Test App", metadata.getName());
    assertTrue(metadata.getGrantTypes().isEmpty());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.