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


Java JsonGenerationException类代码示例

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


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

示例1: writeMetaData

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
@Override
public void writeMetaData(OutputStream out, ResourceWithMetadata resource, Map<String, ResourceWithMetadata> allApiResources) throws IOException
{
    
    final Object result = processResult(resource,allApiResources);

    assistant.getJsonHelper().withWriter(out, new Writer()
    {
        @Override
        public void writeContents(JsonGenerator generator, ObjectMapper objectMapper)
                    throws JsonGenerationException, JsonMappingException, IOException
        {           
           objectMapper.writeValue(generator, result);
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:17,代码来源:WebScriptOptionsMetaData.java

示例2: testWriteValueOutputStreamObject

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
@Test
public void testWriteValueOutputStreamObject() {
  boolean status = true;
  String[] stringArray = new String[1];
  stringArray[0] = "abc";

  new MockUp<ObjectWriter>() {
    @Mock
    public void writeValue(OutputStream out,
        Object value) throws IOException, JsonGenerationException, JsonMappingException {

    }
  };
  try {
    StandardObjectWriter.writeValue(outputStream,
        stringArray);
  } catch (IOException e) {
    status = false;
  }

  Assert.assertTrue(status);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:23,代码来源:TestStandardObjectWriter.java

示例3: testNullInComment

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
@Test
public void testNullInComment() throws IOException
{
    final Comment aComment = new Comment();
    aComment.setContent(null);
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    jsonHelper.withWriter(out, new Writer()
    {
        @Override
        public void writeContents(JsonGenerator generator, ObjectMapper objectMapper)
                    throws JsonGenerationException, JsonMappingException, IOException
        {
            FilterProvider fp = new SimpleFilterProvider().addFilter(
                        JacksonHelper.DEFAULT_FILTER_NAME, new ReturnAllBeanProperties());
            objectMapper.writer(fp).writeValue(generator, aComment);
        }
    });
    assertEquals("Null values should not be output.", "{\"canEdit\":false,\"canDelete\":false}",
                out.toString());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:JsonJacksonTests.java

示例4: toResponse

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
@Override
public Response toResponse(JsonProcessingException exception) {

    if (exception instanceof JsonGenerationException) {
        LOG.error("Error generating JSON", exception);
        return Response.serverError().build();
    }

    if (exception.getMessage().startsWith("No suitable constructor found")) {
        LOG.error("Unable to deserialize the specific type", exception);
        return Response.serverError().build();
    }

    LOG.info(exception.getLocalizedMessage());
    return Response
            .status(Response.Status.BAD_REQUEST)
            .type(MediaType.APPLICATION_JSON_TYPE)
            .entity(createUnauditedErrorStatus(UUID.randomUUID(), ExceptionType.JSON_PARSING, exception.getOriginalMessage()))
            .build();
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:21,代码来源:IdaJsonProcessingExceptionMapper.java

示例5: status

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
@CsapDoc ( notes = { "Summary status of host" } , linkTests = "default" )
@RequestMapping ( { "/status" } )
public ObjectNode status ()
		throws JsonGenerationException, JsonMappingException,
		IOException {

	ObjectNode healthJson = jacksonMapper.createObjectNode();

	if ( Application.isJvmInManagerMode() ) {
		healthJson.put( "error", "vmHealth is only enabled on CsAgent urls." );
	} else {

		healthJson = csapApp.statusForAdminOrAgent( ServiceAlertsEnum.ALERT_LEVEL );
	}

	return healthJson;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:18,代码来源:AgentApi.java

示例6: serialize

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
@Override
public void serialize(SerializablePagedCollection pagedCol, JsonGenerator jgen, SerializerProvider provider)
            throws IOException, JsonGenerationException
{
    if (pagedCol != null)
    {
        jgen.writeStartObject();
        jgen.writeFieldName("list");
            jgen.writeStartObject();
            serializePagination(pagedCol, jgen);
            serializeContext(pagedCol, jgen);
            jgen.writeObjectField("entries", pagedCol.getCollection());
            serializeIncludedSource(pagedCol, jgen);
            jgen.writeEndObject(); 
        jgen.writeEndObject();  
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:18,代码来源:SerializerOfCollectionWithPaging.java

示例7: serviceStop

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
@CsapDoc ( notes = {
		"refer to /api/appication/service"
} , linkTests = {
		"ServletSample" } , linkPaths = { "/serviceStop/ServletSample_8041" } , linkPostParams = {
				"userid=someDeveloper,pass=changeMe,cluster=changeMe,clean=clean" } )
@RequestMapping ( "/serviceStop/{serviceName}" )
@Deprecated
public JsonNode serviceStop (
								@PathVariable ( "serviceName" ) String serviceName_port,
								@RequestParam ( value = "cluster" , defaultValue = "" ) String cluster,
								@RequestParam ( value = "clean" , defaultValue = "" ) String clean,
								@RequestParam ( SpringAuthCachingFilter.USERID ) String userid,
								@RequestParam ( SpringAuthCachingFilter.PASSWORD ) String inputPass,
								HttpServletRequest request )
		throws JsonGenerationException, JsonMappingException, IOException {

	logger.debug( "DeprecatedApi - use /api/application/service/kill" );
	if ( Application.isJvmInManagerMode() ) {
		return applicationApi.serviceKill( serviceName_port, stripOffLifecycle(cluster), clean, "keepLogs", userid, inputPass, request );
	} else {
		ArrayList<String> services = new ArrayList<>() ;
		services.add( serviceName_port ) ;
		return agentApi.serviceKill( services, clean, null, userid, userid, request );
	}
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:26,代码来源:Z_Deprecated.java

示例8: serialize

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
public void serialize(JsonGenerator jgen, BeakerObjectConverter boc) throws JsonGenerationException, IOException {
  jgen.writeStartObject();
  jgen.writeNumberField("width", w);
  if (theStyle!=null) jgen.writeStringField("thestyle", theStyle);
  if (theClass!=null) jgen.writeStringField("theclass", theClass);

  jgen.writeArrayFieldStart("payload");
  for (Object o : payload) {
    if ( o instanceof dashRow ) {
      ((dashRow) o).serialize(jgen, boc);
    } else if (!boc.writeObject(o, jgen, true))
      jgen.writeObject(o.toString());
  }
  jgen.writeEndArray();
  jgen.writeEndObject();
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:17,代码来源:BeakerDashboard.java

示例9: writePrincipals

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
/**
 * Writes the list of <code>Principal</code>s to the JSONGenerator.
 *
 * @param principals
 *            the list of principals to be written.
 */
private void writePrincipals(List<Principal> principals)
        throws JsonGenerationException, IOException {
    if (principals.size() == 1 && principals.get(0).equals(Principal.All)) {
        writeJsonKeyValue(JsonDocumentFields.PRINCIPAL, Principal.All.getId());
    } else {
        writeJsonObjectStart(JsonDocumentFields.PRINCIPAL);

        Map<String, List<String>> principalsByScheme = groupPrincipalByScheme(principals);

        List<String> principalValues;
        for (Map.Entry<String, List<String>> entry : principalsByScheme.entrySet()) {
            principalValues = principalsByScheme.get(entry.getKey());

            if (principalValues.size() == 1) {
                writeJsonKeyValue(entry.getKey(), principalValues.get(0));
            } else {
                writeJsonArray(entry.getKey(), principalValues);
            }

        }
        writeJsonObjectEnd();
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:30,代码来源:JsonPolicyWriter.java

示例10: withWriter

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
/**
 * A callback so a JsonGenerator can be used inline but exception are handled here
 * @param outStream OutputStream
 * @param writer The writer interface
 * @throws IOException
 */
public void withWriter(OutputStream outStream, Writer writer) throws IOException
{
    try
    {
        JsonGenerator generator = objectMapper.getJsonFactory().createJsonGenerator(outStream, encoding);
        writer.writeContents(generator, objectMapper);
    }
    catch (JsonMappingException error)
    {
        logger.error("Failed to write Json output",error);
    } 
    catch (JsonGenerationException generror)
    {
        logger.error("Failed to write Json output",generror);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:JacksonHelper.java

示例11: writeConditions

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
/**
 * Writes the list of conditions to the JSONGenerator.
 *
 * @param conditions
 *            the conditions to be written.
 */
private void writeConditions(List<Condition> conditions)
        throws JsonGenerationException, IOException {
    Map<String, ConditionsByKey> conditionsByType = groupConditionsByTypeAndKey(conditions);

    writeJsonObjectStart(JsonDocumentFields.CONDITION);

    ConditionsByKey conditionsByKey;
    for (Map.Entry<String, ConditionsByKey> entry : conditionsByType
            .entrySet()) {
        conditionsByKey = conditionsByType.get(entry.getKey());

        writeJsonObjectStart(entry.getKey());
        for (String key : conditionsByKey.keySet()) {
            writeJsonArray(key, conditionsByKey.getConditionsByKey(key));
        }
        writeJsonObjectEnd();
    }
    writeJsonObjectEnd();
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:26,代码来源:JsonPolicyWriter.java

示例12: testSerializeComment

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
@Test
public void testSerializeComment() throws IOException
{
    final Comment aComment = new Comment();
    aComment.setContent("<b>There it is</b>");
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    jsonHelper.withWriter(out, new Writer()
    {
        @Override
        public void writeContents(JsonGenerator generator, ObjectMapper objectMapper)
                    throws JsonGenerationException, JsonMappingException, IOException
        {
            FilterProvider fp = new SimpleFilterProvider().addFilter(
                        JacksonHelper.DEFAULT_FILTER_NAME, new ReturnAllBeanProperties());
            objectMapper.writer(fp).writeValue(generator, aComment);
        }
    });
    assertTrue(out.toString().contains("{\"content\":\"<b>There it is</b>\""));
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:JsonJacksonTests.java

示例13: logShouldSwallowExceptions

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
@Test
public void logShouldSwallowExceptions() throws JsonProcessingException {
    SystemFragment frag = SystemFragment.empty();
    Mockito.when(analyzerMock.analyzeSystem()).thenReturn(frag);
    Mockito.when(objectMapperMock.writeValueAsString(frag)).thenThrow(Mockito.mock(JsonGenerationException.class));
    logSnitch.log();
    Mockito.verify(analyzerMock).analyzeSystem();
    Mockito.verify(objectMapperMock).writeValueAsString(frag);

}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:11,代码来源:Slf4jSnitchLoggerTest.java

示例14: serialize

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
@Override
public void serialize(CategoryEntity value, JsonGenerator gen, SerializerProvider provider) throws IOException {
    if (null == value) {
        throw new JsonGenerationException("Could not serialize object to json, input object to serialize is null");
    }
    StringWriter writer = new StringWriter();
    mapper.writeValue(writer, value);
    gen.writeFieldName(writer.toString());
}
 
开发者ID:Sugarya,项目名称:JSONParserMapTest,代码行数:10,代码来源:MapKeySerializer.java

示例15: serialize

import com.fasterxml.jackson.core.JsonGenerationException; //导入依赖的package包/类
@Override
public void serialize(JSONOptions value, JsonGenerator jgen, SerializerProvider provider) throws IOException,
    JsonGenerationException {
  if (value.opaque != null) {
    jgen.writeObject(value.opaque);
  } else {
    jgen.writeTree(value.root);
  }

}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:JSONOptions.java


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