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


Java JsonParsingException类代码示例

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


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

示例1: validateEntityToken

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
public static String validateEntityToken(Key key, String jwt) {

        JwtConsumer jwtConsumer = new JwtConsumerBuilder()
                .setVerificationKey(key)
                .setRelaxVerificationKeyValidation()
                .build();

        try {
            JwtClaims jwtClaims = jwtConsumer.processToClaims(jwt);
            String subject = jwtClaims.getSubject();
            try (JsonReader reader = Json.createReader(new StringReader(subject))) {
                JsonObject subjectObject = reader.readObject(); // JsonParsingException
                return subjectObject.getString(ENTITY_KEY); // Npe
            }
        } catch (InvalidJwtException | MalformedClaimException | JsonParsingException | NullPointerException e) {
            LOGGER.log(Level.SEVERE, "Cannot validate jwt token", e);
        }

        return null;

    }
 
开发者ID:polarsys,项目名称:eplmp,代码行数:22,代码来源:JWTokenFactory.java

示例2: resolveOutputJson

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
private JsonObject resolveOutputJson(Return testArtefact) {
	String outputJson = testArtefact.getOutput().get();
	
	JsonObject outputJsonObject;
	try {
		if(outputJson!=null&&outputJson.trim().length()>0) {
			outputJsonObject = jprov.createReader(new StringReader(outputJson)).readObject();
		} else {
			outputJsonObject = jprov.createObjectBuilder().build();
		}
	} catch(JsonParsingException e) {
		throw new RuntimeException("Error while parsing argument (input): "+e.getMessage());
	}
	
	JsonObject outputJsonAfterResolving = dynamicJsonObjectResolver.evaluate(outputJsonObject, getBindings());
	return outputJsonAfterResolving;
}
 
开发者ID:denkbar,项目名称:step,代码行数:18,代码来源:ReturnHandler.java

示例3: getJsonParser

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
public static CookJsonParser getJsonParser (InputStream is)
{
	PushbackInputStream pis = new PushbackInputStream (is, 3);
	Charset charset;
	try
	{
		charset = BOM.guessCharset (pis);
	}
	catch (IOException ex)
	{
		JsonLocationImpl location = new JsonLocationImpl ();
		location.m_streamOffset = 0;
		throw new JsonParsingException (ex.getMessage (), ex, location);
	}
	if (charset == BOM.utf8)
		return new UTF8TextJsonParser (pis);
	return new TextJsonParser (new InputStreamReader (pis, charset));
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:19,代码来源:TextJsonConfigHandler.java

示例4: testError1

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
@Test
public void testError1 ()
{
	String json = "{\"a\" :\n//abc\u0000\n 99e12 }";

    thrown.expect (JsonParsingException.class);
    thrown.expectMessage ("Parsing error at line 2, column 6, offset 12: unexpected character '\\u0000'");

    TextJsonParser p = new TextJsonParser (new StringReader (json), 2);
    p.setAllowComments (true);
	while (p.hasNext ())
	{
		p.next ();
	}
	p.close ();
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:17,代码来源:CommentTest.java

示例5: testError2

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
@Test
public void testError2 ()
{
	String json = "{\"a\" :\n/*abc\u0000\n*/ 99e12 }";

    thrown.expect (JsonParsingException.class);
    thrown.expectMessage ("Parsing error at line 2, column 6, offset 12: unexpected character '\\u0000'");

    TextJsonParser p = new TextJsonParser (new StringReader (json));
    p.setAllowComments (true);
	while (p.hasNext ())
	{
		p.next ();
	}
	p.close ();
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:17,代码来源:CommentTest.java

示例6: testError2_2

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
@Test
public void testError2_2 ()
{
	String json = "{\"a\" :\n/*abc\u0000\n*/ 99e12 }";

    thrown.expect (JsonParsingException.class);
    thrown.expectMessage ("Parsing error at line 2, column 6, offset 12: unexpected character '\\u0000'");

    TextJsonParser p = new TextJsonParser (new StringReader (json), 2);
    p.setAllowComments (true);
	while (p.hasNext ())
	{
		p.next ();
	}
	p.close ();
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:17,代码来源:CommentTest.java

示例7: testError3

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
@Test
public void testError3 ()
{
	String json = "{\"a\" :\n/****\u0000\n*/ 99e12 }";

    thrown.expect (JsonParsingException.class);
    thrown.expectMessage ("Parsing error at line 2, column 6, offset 12: unexpected character '\\u0000'");

    TextJsonParser p = new TextJsonParser (new StringReader (json));
    p.setAllowComments (true);
	while (p.hasNext ())
	{
		p.next ();
	}
	p.close ();
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:17,代码来源:CommentTest.java

示例8: testError1

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
@Test
public void testError1 ()
{
	String json = "{\"a\" :\n//abc\u0000\n 99e12 }";

    thrown.expect (JsonParsingException.class);
    thrown.expectMessage ("Parsing error at line 2, column 6, offset 12: unexpected character '\\u0000'");

    UTF8TextJsonParser p = new UTF8TextJsonParser (new ByteArrayInputStream (json.getBytes (BOM.utf8)), 2);
    p.setAllowComments (true);
	while (p.hasNext ())
	{
		p.next ();
	}
	p.close ();
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:17,代码来源:UTF8CommentTest.java

示例9: testError3_2

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
@Test
public void testError3_2 ()
{
	String json = "{\"a\" :\n/****\u0000\n*/ 99e12 }";

    thrown.expect (JsonParsingException.class);
    thrown.expectMessage ("Parsing error at line 2, column 6, offset 12: unexpected character '\\u0000'");

    UTF8TextJsonParser p = new UTF8TextJsonParser (new ByteArrayInputStream (json.getBytes (BOM.utf8)), 2);
    p.setAllowComments (true);
	while (p.hasNext ())
	{
		p.next ();
	}
	p.close ();
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:17,代码来源:UTF8CommentTest.java

示例10: stringToJsonObj

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
private JsonObject stringToJsonObj(String input) {
  try {
    JsonReader jsonReader = Json.createReader(new StringReader(input));
    JsonObject output = jsonReader.readObject();
    jsonReader.close();
    return output;
  } catch (JsonParsingException e) {
    return null;
  }
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:11,代码来源:Orchestrator.java

示例11: stringToJsonObj

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
public static JsonObject stringToJsonObj(String input) {
  try {
    JsonReader jsonReader = Json.createReader(new StringReader(input));
    JsonObject output = jsonReader.readObject();
    jsonReader.close();
    return output;
  } catch (JsonParsingException e) {
    return null;
  }
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:11,代码来源:Group.java

示例12: validateAuthToken

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
public static JWTokenUserGroupMapping validateAuthToken(Key key, String jwt) {

        JwtConsumer jwtConsumer = new JwtConsumerBuilder()
                .setVerificationKey(key)
                .setRelaxVerificationKeyValidation()
                .build();

        try {
            JwtClaims jwtClaims = jwtConsumer.processToClaims(jwt);
            String subject = jwtClaims.getSubject();

            try (JsonReader reader = Json.createReader(new StringReader(subject))) {
                JsonObject subjectObject = reader.readObject(); // JsonParsingException
                String login = subjectObject.getString(SUBJECT_LOGIN); // Npe
                String groupName = subjectObject.getString(SUBJECT_GROUP_NAME); // Npe

                if (login != null && !login.isEmpty() && groupName != null && !groupName.isEmpty()) {
                    return new JWTokenUserGroupMapping(jwtClaims, new UserGroupMapping(login, groupName));
                }
            }


        } catch (InvalidJwtException | MalformedClaimException | JsonParsingException | NullPointerException e) {
            LOGGER.log(Level.SEVERE, "Cannot validate jwt token", e);
        }

        return null;

    }
 
开发者ID:polarsys,项目名称:eplmp,代码行数:30,代码来源:JWTokenFactory.java

示例13: testError6

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
@Test
@SuppressWarnings ("resource")
public void testError6 ()
{
	String json = "\u0000{ \"a\" : 1 ]";

	thrown.expect (JsonParsingException.class);
	thrown.expectMessage ("Parsing error at line 1, column 1, offset 0: unexpected character '\\u0000'");

	JsonParser p = new UTF8TextJsonParser (new ByteArrayInputStream (json.getBytes (BOM.utf8)));
	for (;;)
	{
		p.next ();
	}
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:16,代码来源:UTF8TextJsonParserErrorTest.java

示例14: testIOError

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
@Test
@SuppressWarnings ("resource")
public void testIOError ()
{
	String json = "[{";

	thrown.expect (JsonParsingException.class);
	thrown.expectMessage ("Parsing error at line 1, column 3, offset 2: unexpected eof");

	JsonParser p = new UTF8TextJsonParser (new ByteArrayInputStream (json.getBytes (BOM.utf8)));
	for (;;)
	{
		p.next ();
	}
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:16,代码来源:UTF8TextJsonParserErrorTest.java

示例15: testInvalidHeader

import javax.json.stream.JsonParsingException; //导入依赖的package包/类
@Test(expected = JsonParsingException.class)
public void testInvalidHeader() throws DataFormatException {
  String clientSecret = "SECRET_KEY";
  String idTokenString =
      "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ.eyJpc3MiOiJodHRwczpcL1wvYXV0aC5sb2dpbi55YWhvby5jby5qcCIsInVzZXJfaWQiOiJVU0VSX0lEIiwiYXVkIjoiQVBQTElDQVRJT05fSUQiLCJleHAiOjE0MTE2NDcxMzksImlhdCI6MTQxMDQzNzU0MCwibm9uY2UiOiJhYmNkZWZnIn0.OLUFkAlp4BwwAxniMzXyoR5ZFC3Q5HCNHRvR6qDf-zY";
  JWTVerification verifier = new JWTVerification(clientSecret, idTokenString);
  boolean result = verifier.verifyJWT();
  assertFalse(result);
}
 
开发者ID:yahoojapan,项目名称:yconnect-servlet-sdk,代码行数:10,代码来源:JWTVerificationTest.java


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