當前位置: 首頁>>代碼示例>>Java>>正文


Java Feature類代碼示例

本文整理匯總了Java中com.fasterxml.jackson.core.JsonParser.Feature的典型用法代碼示例。如果您正苦於以下問題:Java Feature類的具體用法?Java Feature怎麽用?Java Feature使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Feature類屬於com.fasterxml.jackson.core.JsonParser包,在下文中一共展示了Feature類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initialize

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
private StructObjectInspector initialize(final ObjectInspector jsonArg, final ObjectInspector jqArg, final List<ObjectInspector> nameAndTypeArgs) throws UDFArgumentException {
	this.in = Arguments.asString(jsonArg, "JSON");

	try {
		this.jq = JsonQuery.compile(Arguments.asConstantNonNullString(jqArg, "JQ"));
	} catch (final JsonQueryException e) {
		throw new UDFArgumentException("JQ is invalid: " + e.getMessage());
	}

	this.marshaller = ResultObjectMarshallers.create(Arguments.asConstantNonNullStrings(nameAndTypeArgs, "TYPE or NAME:TYPE"));

	this.scope = new Scope();
	this.mapper = new ObjectMapper(new JsonFactory().enable(Feature.ALLOW_UNQUOTED_CONTROL_CHARS));

	return marshaller.objectInspector();
}
 
開發者ID:CyberAgent,項目名稱:hive-jq-udtf,代碼行數:17,代碼來源:JsonQueryUDTF.java

示例2: testArrayInnerComma

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
@Test
  public void testArrayInnerComma() throws Exception {
  String json = "[\"a\",, \"b\"]";

  AsyncReaderWrapper p = createParser(factory, json);

  assertEquals(JsonToken.START_ARRAY, p.nextToken());

  assertToken(JsonToken.VALUE_STRING, p.nextToken());
  assertEquals("a", p.currentText());

  if (!features.contains(Feature.ALLOW_MISSING_VALUES)) {
    assertUnexpected(p, ',');
    return;
  }

  assertToken(JsonToken.VALUE_NULL, p.nextToken());

  assertToken(JsonToken.VALUE_STRING, p.nextToken());
  assertEquals("b", p.currentText());

  assertEquals(JsonToken.END_ARRAY, p.nextToken());
  assertEnd(p);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:AsyncMissingValuesInArrayTest.java

示例3: testArrayLeadingComma

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
@Test
public void testArrayLeadingComma() throws Exception {
  String json = "[,\"a\", \"b\"]";

  AsyncReaderWrapper p = createParser(factory, json);

  assertEquals(JsonToken.START_ARRAY, p.nextToken());

  if (!features.contains(Feature.ALLOW_MISSING_VALUES)) {
    assertUnexpected(p, ',');
    return;
  }

  assertToken(JsonToken.VALUE_NULL, p.nextToken());

  assertToken(JsonToken.VALUE_STRING, p.nextToken());
  assertEquals("a", p.currentText());

  assertToken(JsonToken.VALUE_STRING, p.nextToken());
  assertEquals("b", p.currentText());

  assertEquals(JsonToken.END_ARRAY, p.nextToken());
  assertEnd(p);
  p.close();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:AsyncMissingValuesInArrayTest.java

示例4: testObjectTrailingComma

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
@Test
public void testObjectTrailingComma() throws Exception {
  String json = "{\"a\": true, \"b\": false,}";

  AsyncReaderWrapper p = createParser(factory, json);

  assertEquals(JsonToken.START_OBJECT, p.nextToken());

  assertToken(JsonToken.FIELD_NAME, p.nextToken());
  assertEquals("a", p.currentText());
  assertToken(JsonToken.VALUE_TRUE, p.nextToken());

  assertToken(JsonToken.FIELD_NAME, p.nextToken());
  assertEquals("b", p.currentText());
  assertToken(JsonToken.VALUE_FALSE, p.nextToken());

  if (features.contains(Feature.ALLOW_TRAILING_COMMA)) {
    assertToken(JsonToken.END_OBJECT, p.nextToken());
    assertEnd(p);
  } else {
    assertUnexpected(p, '}');
  }
  p.close();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:AsyncMissingValuesInObjectTest.java

示例5: testArrayInnerComma

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
@SuppressWarnings("resource")
@Test
public void testArrayInnerComma() throws Exception {
  String json = "[\"a\",, \"b\"]";

  JsonParser p = createParser(factory, mode, json);

  assertEquals(JsonToken.START_ARRAY, p.nextToken());

  assertToken(JsonToken.VALUE_STRING, p.nextToken());
  assertEquals("a", p.getText());

  if (!features.contains(Feature.ALLOW_MISSING_VALUES)) {
    assertUnexpected(p, ',');
    return;
  }

  assertToken(JsonToken.VALUE_NULL, p.nextToken());

  assertToken(JsonToken.VALUE_STRING, p.nextToken());
  assertEquals("b", p.getText());

  assertEquals(JsonToken.END_ARRAY, p.nextToken());
  assertEnd(p);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:TrailingCommasTest.java

示例6: testArrayLeadingComma

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
@SuppressWarnings("resource")
@Test
public void testArrayLeadingComma() throws Exception {
  String json = "[,\"a\", \"b\"]";

  JsonParser p = createParser(factory, mode, json);

  assertEquals(JsonToken.START_ARRAY, p.nextToken());

  if (!features.contains(Feature.ALLOW_MISSING_VALUES)) {
    assertUnexpected(p, ',');
    return;
  }

  assertToken(JsonToken.VALUE_NULL, p.nextToken());

  assertToken(JsonToken.VALUE_STRING, p.nextToken());
  assertEquals("a", p.getText());

  assertToken(JsonToken.VALUE_STRING, p.nextToken());
  assertEquals("b", p.getText());

  assertEquals(JsonToken.END_ARRAY, p.nextToken());
  assertEnd(p);
  p.close();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:TrailingCommasTest.java

示例7: testObjectTrailingComma

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
@Test
public void testObjectTrailingComma() throws Exception {
  String json = "{\"a\": true, \"b\": false,}";

  JsonParser p = createParser(factory, mode, json);

  assertEquals(JsonToken.START_OBJECT, p.nextToken());

  assertToken(JsonToken.FIELD_NAME, p.nextToken());
  assertEquals("a", p.getText());
  assertToken(JsonToken.VALUE_TRUE, p.nextToken());

  assertToken(JsonToken.FIELD_NAME, p.nextToken());
  assertEquals("b", p.getText());
  assertToken(JsonToken.VALUE_FALSE, p.nextToken());

  if (features.contains(Feature.ALLOW_TRAILING_COMMA)) {
    assertToken(JsonToken.END_OBJECT, p.nextToken());
    assertEnd(p);
  } else {
    assertUnexpected(p, '}');
  }
  p.close();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:TrailingCommasTest.java

示例8: LogicalPlanPersistence

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
public LogicalPlanPersistence(SabotConfig conf, ScanResult scanResult) {
  mapper = new ObjectMapper();

  SimpleModule deserModule = new SimpleModule("LogicalExpressionDeserializationModule")
      .addDeserializer(LogicalExpression.class, new LogicalExpression.De(conf))
      .addDeserializer(SchemaPath.class, new SchemaPath.De());

  mapper.registerModule(new AfterburnerModule());
  mapper.registerModule(deserModule);
  mapper.enable(SerializationFeature.INDENT_OUTPUT);
  mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
  mapper.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
  mapper.configure(Feature.ALLOW_COMMENTS, true);
  registerSubtypes(LogicalOperatorBase.getSubTypes(scanResult));
  registerSubtypes(StoragePluginConfigBase.getSubTypes(scanResult));
  registerSubtypes(FormatPluginConfigBase.getSubTypes(scanResult));
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:18,代碼來源:LogicalPlanPersistence.java

示例9: readServiceInformation

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
/**
 * Reads service information.
 *
 * @param folder folder
 * @param si service info obtained through {@link listContent}
 * @return service response
 * @throws URISyntaxException if invalid URL
 * @throws IOException if accessing token fails
 */
public ServerResponse readServiceInformation(String folder, ServiceInfo si) throws URISyntaxException, IOException {
  String url = rootUrl.toURI().resolve("rest/services/").resolve(StringUtils.stripToEmpty(folder)).resolve(si.name + "/" + si.type).toASCIIString();
  HttpGet get = new HttpGet(url + String.format("?f=%s", "json"));

  try (CloseableHttpResponse httpResponse = httpClient.execute(get); InputStream contentStream = httpResponse.getEntity().getContent();) {
    if (httpResponse.getStatusLine().getStatusCode()>=400) {
      throw new HttpResponseException(httpResponse.getStatusLine().getStatusCode(), httpResponse.getStatusLine().getReasonPhrase());
    }
    String responseContent = IOUtils.toString(contentStream, "UTF-8");
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.configure(Feature.ALLOW_NON_NUMERIC_NUMBERS, true);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    ServerResponse response = mapper.readValue(responseContent, ServerResponse.class);
    response.url = url;
    response.json = responseContent;
    return response;
  }
}
 
開發者ID:Esri,項目名稱:geoportal-server-harvester,代碼行數:29,代碼來源:AgsClient.java

示例10: JacksonObjectMapperConfig

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
public JacksonObjectMapperConfig() {
	super();
	
	this.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);		
	//this.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); 不增加,避免key值為null,而避免節點消失
	this.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	this.configure(Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); 
	
	//this.setSerializationInclusion(Include.NON_EMPTY); //對象轉字符串時,隻轉化非空字段 zjs 需要占位
	
	//SimpleModule module = new SimpleModule();
       SimpleModule module = new SimpleModule("HTML XSS Serializer",
               new Version(1, 0, 0, "FINAL", "com.simbest", "ep-jsonmodule"));
       module.addSerializer(new JsonHtmlXssSerializer(String.class));
       module.addDeserializer(Date.class, new CustomJsonDateDeseralizer());
       // Add more here ...
       registerModule(module);
}
 
開發者ID:simbest,項目名稱:simbest-cores,代碼行數:19,代碼來源:JacksonObjectMapperConfig.java

示例11: setStatusMessage

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
public void setStatusMessage(String statusMessage) {
	try {
		ObjectMapper mapper = new ObjectMapper();
		mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES,true);
		mapper.configure(Feature.ALLOW_SINGLE_QUOTES,true);
		mapper.configure(Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
		JsonNode node = mapper.readValue(statusMessage.getBytes(), JsonNode.class);
		this.statusMessage = node.get("statusMessage").asText();
		this.additionalInfo = node.get("additionalInfo");
		this.step = node.get("step").asText();
	} catch (Exception e) {
		System.out.println(statusMessage);
	//	e.printStackTrace();
	}

}
 
開發者ID:hserv,項目名稱:coordinated-entry,代碼行數:17,代碼來源:MatchProcessLog.java

示例12: LogicalPlanPersistence

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
public LogicalPlanPersistence(DrillConfig conf, ScanResult scanResult) {
  mapper = new ObjectMapper();

  SimpleModule deserModule = new SimpleModule("LogicalExpressionDeserializationModule")
      .addDeserializer(LogicalExpression.class, new LogicalExpression.De(conf))
      .addDeserializer(SchemaPath.class, new SchemaPath.De());

  mapper.registerModule(deserModule);
  mapper.enable(SerializationFeature.INDENT_OUTPUT);
  mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
  mapper.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
  mapper.configure(Feature.ALLOW_COMMENTS, true);
  registerSubtypes(LogicalOperatorBase.getSubTypes(scanResult));
  registerSubtypes(StoragePluginConfigBase.getSubTypes(scanResult));
  registerSubtypes(FormatPluginConfigBase.getSubTypes(scanResult));
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:17,代碼來源:LogicalPlanPersistence.java

示例13: fromJSON

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
/**
 * Convenience static method that reads a JSON string from the given stream and converts the JSON
 * string to a particular message object. The input stream will remain open so the caller can
 * stream any extra data that might appear after it.
 *
 * Because of the way the JSON parser works, some extra data might have been read from the stream
 * that wasn't part of the JSON message but was part of the extra data that came with it. Because of this,
 * the caller should no longer use the given stream but instead read the extra data via the returned
 * object (see {@link BasicMessageWithExtraData#getBinaryData()}) since it will handle this condition
 * properly.
 *
 * @param in input stream that has a JSON string at the head.
 * @param clazz the class whose instance is represented by the JSON string
 *
 * @return a POJO that contains a message object that was represented by the JSON string found
 *         in the stream. This returned POJO will also contain a {@link BinaryData} object that you
 *         can use to stream any additional data that came in the given input stream.
 */
public static <T extends BasicMessage> BasicMessageWithExtraData<T> fromJSON(InputStream in, Class<T> clazz) {
    final T obj;
    final byte[] remainder;
    try (JsonParser parser = new JsonFactory().configure(Feature.AUTO_CLOSE_SOURCE, false).createParser(in)) {
        Method buildObjectMapperForDeserializationMethod = findBuildObjectMapperForDeserializationMethod(clazz);

        final ObjectMapper mapper = (ObjectMapper) buildObjectMapperForDeserializationMethod.invoke(null);
        if (FailOnUnknownProperties.class.isAssignableFrom(clazz)) {
            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
        }

        obj = mapper.readValue(parser, clazz);
        final ByteArrayOutputStream remainderStream = new ByteArrayOutputStream();
        final int released = parser.releaseBuffered(remainderStream);
        remainder = (released > 0) ? remainderStream.toByteArray() : new byte[0];
    } catch (Exception e) {
        throw new IllegalArgumentException("Stream cannot be converted to JSON object of type [" + clazz + "]", e);
    }
    return new BasicMessageWithExtraData<T>(obj, new BinaryData(remainder, in));
}
 
開發者ID:hawkular,項目名稱:hawkular-bus,代碼行數:39,代碼來源:AbstractMessage.java

示例14: jsonObjectMapper

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
@Bean
public ObjectMapper jsonObjectMapper() {
	final ObjectMapper jsonMapper = new ObjectMapper();
	jsonMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
	jsonMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	jsonMapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
	jsonMapper.configure(Feature.ALLOW_SINGLE_QUOTES, true);
	jsonMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false);

	final SimpleModule module = new SimpleModule("FieldsMapping", Version.unknownVersion());
	module.setSerializerModifier(new BeanSerializerModifier() {
		@Override
		public JsonSerializer<?> modifyMapSerializer(final SerializationConfig config, final MapType valueType,
				final BeanDescription beanDesc, final JsonSerializer<?> serializer) {
			if (FieldsMap.class.isAssignableFrom(valueType.getRawClass())) {
				return new FieldsMapMixInLikeSerializer();
			} else {
				return super.modifyMapSerializer(config, valueType, beanDesc, serializer);
			}
		}
	});
	jsonMapper.registerModule(module);
	return jsonMapper;
}
 
開發者ID:logsniffer,項目名稱:logsniffer,代碼行數:25,代碼來源:CoreAppConfig.java

示例15: _skipComment

import com.fasterxml.jackson.core.JsonParser.Feature; //導入依賴的package包/類
private void _skipComment()
{
  if (!isEnabled(JsonParser.Feature.ALLOW_COMMENTS))
    _reportUnexpectedChar(47, "maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)");
  if ((this._inputPtr >= this._inputEnd) && (!loadMore()))
    _reportInvalidEOF(" in a comment");
  byte[] arrayOfByte = this._inputBuffer;
  int i = this._inputPtr;
  this._inputPtr = (i + 1);
  int j = 0xFF & arrayOfByte[i];
  if (j == 47)
  {
    _skipCppComment();
    return;
  }
  if (j == 42)
  {
    _skipCComment();
    return;
  }
  _reportUnexpectedChar(j, "was expecting either '*' or '/' for a comment");
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:23,代碼來源:UTF8StreamJsonParser.java


注:本文中的com.fasterxml.jackson.core.JsonParser.Feature類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。