• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java JsonIterator类的典型用法和代码示例

java 1次浏览

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

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

示例1: run

点赞 3

import com.jsoniter.JsonIterator; //导入依赖的package包/类
public void run() {
    System.out.printf("%s %s %s %s", framework, model, config, output);
    FrameworkRegistry registry = FrameworkRegistry.getInstance();
    Set<String> frameworks = registry.getFrameworks();
    if(frameworks.contains(framework)) {
        Generator generator = registry.getGenerator(framework);
        try {
            Object anyModel = null;
            // model can be empty in some cases.
            if(model != null) {
                // check if model is json or not before loading.
                if(model.endsWith("json")) {
                    if(isUrl(model)) {
                        anyModel = JsonIterator.deserialize(urlToByteArray(new URL(model)));
                    } else {
                        anyModel = JsonIterator.deserialize(Files.readAllBytes(Paths.get(model)));
                    }
                } else {
                    if(isUrl(model)) {
                        anyModel = new String(urlToByteArray(new URL(model)), StandardCharsets.UTF_8);
                    } else {
                        anyModel = new String(Files.readAllBytes(Paths.get(model)), StandardCharsets.UTF_8);
                    }
                }
            }

            Any anyConfig = null;
            if(isUrl(config)) {
                anyConfig = JsonIterator.deserialize(urlToByteArray(new URL(config)));
            } else {
                anyConfig = JsonIterator.deserialize(Files.readAllBytes(Paths.get(config)));
            }
           generator.generate(output, anyModel, anyConfig);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        System.out.printf("Invalid framework %s", framework);
    }
}
 

开发者ID:networknt,
项目名称:light-codegen,
代码行数:41,
代码来源:Cli.java

示例2: readFrom

点赞 3

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Override
public Object readFrom(
    Class<Object> aClass,
    Type type,
    Annotation[] annotations,
    MediaType mediaType,
    MultivaluedMap<String, String> multivaluedMap,
    InputStream inputStream)
    throws IOException, WebApplicationException {
  StringWriter writer = new StringWriter();
  IOUtils.copy(inputStream, writer);
  String theString = writer.toString();

  JsonIterator smth = JsonIterator.parse(theString);
  Object retval = smth.read(type);
  return retval;
}
 

开发者ID:cubedb,
项目名称:cubedb,
代码行数:18,
代码来源:JsonIteratorConverter.java

示例3: decode_

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
public static Object decode_(JsonIterator iter) throws java.io.IOException {
    if (iter.readNull()) {
        com.jsoniter.CodegenAccess.resetExistingObject(iter);
        return null;
    }
    JsonIteratorImageTest.Model obj = (com.jsoniter.CodegenAccess.existingObject(iter) == null ? new JsonIteratorImageTest.Model() : (JsonIteratorImageTest.Model)com.jsoniter.CodegenAccess.resetExistingObject(iter));
    if (!com.jsoniter.CodegenAccess.readObjectStart(iter)) { return obj; }
    switch (com.jsoniter.CodegenAccess.readObjectFieldAsHash(iter)) {
        case 926444256:
            obj.id = (int)iter.readInt();
            break;
        case -1925595674:
            obj.name = (String)iter.readString();
            break;
        default:
            iter.skip();
    }
    while (com.jsoniter.CodegenAccess.nextToken(iter) == ',') {
        switch (com.jsoniter.CodegenAccess.readObjectFieldAsHash(iter)) {
            case 926444256:
                obj.id = (int)iter.readInt();
                continue;
            case -1925595674:
                obj.name = (String)iter.readString();
                continue;
        }
        iter.skip();
    }
    return obj;
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:31,
代码来源:JsonIteratorImageTest.java

示例4: benchSetup

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) {
    //JsonIterator.enableAnnotationSupport();
    JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
    JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
    testObject = TestObject.createTestObject();
    stream = new JsonStream(null, 512);
    byteArrayOutputStream = new ByteArrayOutputStream();
}
 

开发者ID:json-iterator,
项目名称:java-benchmark,
代码行数:10,
代码来源:SerJsoniter.java

示例5: benchSetup

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) {
    JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
    JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
    testJSON = TestObject.createTestJSON();
    iter = new JsonIterator();
    typeLiteral = TypeLiteral.create(TestObject.class);
}
 

开发者ID:json-iterator,
项目名称:java-benchmark,
代码行数:9,
代码来源:DeserJsoniter.java

示例6: benchSetup

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) {
    JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
    JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
    iter = new JsonIterator();
    typeLiteral = TypeLiteral.create(TestReadObject.class);
}
 

开发者ID:json-iterator,
项目名称:java-benchmark,
代码行数:8,
代码来源:DeserJsoniter.java

示例7: benchSetup

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Setup(Level.Trial)
    public void benchSetup(BenchmarkParams params) {
//        JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
        JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
        testJSON = TestObject.createTestJSON();
        iter = new JsonIterator();
        typeLiteral = TypeLiteral.create(TestObject.class);
    }
 

开发者ID:json-iterator,
项目名称:java-benchmark,
代码行数:9,
代码来源:DeserJsoniter.java

示例8: benchSetup

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) {
    Base64FloatSupport.enableEncodersAndDecoders();
    JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
    JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
    testObject = TestObject.createTestObject();
    stream = new JsonStream(null, 512);
    byteArrayOutputStream = new ByteArrayOutputStream();
}
 

开发者ID:json-iterator,
项目名称:java-benchmark,
代码行数:10,
代码来源:SerJsoniter.java

示例9: benchSetup

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) {
    Base64FloatSupport.enableEncodersAndDecoders();
    JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
    JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
    testJSON = TestObject.createTestJSON();
    iter = new JsonIterator();
    typeLiteral = TypeLiteral.create(TestObject.class);
}
 

开发者ID:json-iterator,
项目名称:java-benchmark,
代码行数:10,
代码来源:DeserJsoniter.java

示例10: benchSetup

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) {
    Base64FloatSupport.enableEncodersAndDecoders();
    JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
    JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
    testJSON = TestObject.createTestJSON();
    System.out.println(new String(testJSON));
    iter = new JsonIterator();
    typeLiteral = TypeLiteral.create(TestObject.class);
}
 

开发者ID:json-iterator,
项目名称:java-benchmark,
代码行数:11,
代码来源:DeserJsoniter.java

示例11: benchSetup

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Setup(Level.Trial)
    public void benchSetup(BenchmarkParams params) {
//        JsonIterator.enableAnnotationSupport();
        JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
        JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
        testObject = TestObject.createTestObject();
        stream = new JsonStream(null, 512);
        byteArrayOutputStream = new ByteArrayOutputStream();
    }
 

开发者ID:json-iterator,
项目名称:java-benchmark,
代码行数:10,
代码来源:SerJsoniter.java

示例12: benchSetup

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) {
    JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
    JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
    testObject = TestObject.createTestObject();
    stream = new JsonStream(null, 512);
    byteArrayOutputStream = new ByteArrayOutputStream();
}
 

开发者ID:json-iterator,
项目名称:java-benchmark,
代码行数:9,
代码来源:SerJsoniter.java

示例13: benchSetup

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) {
    JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
    JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_STRICTLY);
    testJSON = TestObject.createTestJSON();
    iter = new JsonIterator();
    typeLiteral = TypeLiteral.create(TestObject.class);
}
 

开发者ID:json-iterator,
项目名称:java-benchmark,
代码行数:9,
代码来源:DeserJsoniter.java

示例14: benchSetup

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Setup(Level.Trial)
    public void benchSetup(BenchmarkParams params) {
//        JsonIterator.enableAnnotationSupport();
        JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
        JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
        testObject = TestObject.createTestObject();
        testObject.field1 = "12345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678";
        stream = new JsonStream(null, 4096);
        byteArrayOutputStream = new ByteArrayOutputStream();
    }
 

开发者ID:json-iterator,
项目名称:java-benchmark,
代码行数:11,
代码来源:SerJsoniter.java

示例15: benchSetup

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Setup(Level.Trial)
    public void benchSetup(BenchmarkParams params) {
        JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
        JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
        testJSON = Arrays.asList(
                TestObject.createRandomTestJson(),
                TestObject.createRandomTestJson(),
                TestObject.createRandomTestJson(),
                TestObject.createRandomTestJson(),
                TestObject.createRandomTestJson(),
                TestObject.createRandomTestJson(),
                TestObject.createRandomTestJson(),
                TestObject.createRandomTestJson(),
                TestObject.createRandomTestJson(),
                TestObject.createRandomTestJson());
//        byte[] fixed = TestObject.createRandomTestJson();
//        testJSON = Arrays.asList(
//                fixed,
//                fixed,
//                fixed,
//                fixed,
//                fixed,
//                fixed,
//                fixed,
//                fixed,
//                fixed,
//                fixed);
        iter = new JsonIterator();
        typeLiteral = TypeLiteral.create(TestObject.class);
    }
 

开发者ID:json-iterator,
项目名称:java-benchmark,
代码行数:31,
代码来源:DeserJsoniter.java

示例16: testGenerator

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Test
public void testGenerator() throws IOException {
    Any anyConfig = JsonIterator.parse(OpenApiGeneratorTest.class.getResourceAsStream(configName), 1024).readAny();
    Any anyModel = JsonIterator.parse(OpenApiGeneratorTest.class.getResourceAsStream(openapiName), 1024).readAny();

    OpenApiGenerator generator = new OpenApiGenerator();
    generator.generate(targetPath, anyModel, anyConfig);
}
 

开发者ID:networknt,
项目名称:light-codegen,
代码行数:9,
代码来源:OpenApiGeneratorTest.java

示例17: testGetOperationList

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Test
public void testGetOperationList() throws IOException {
    Any anyModel = JsonIterator.parse(SwaggerGeneratorTest.class.getResourceAsStream(openapiName), 1024).readAny();
    OpenApiGenerator generator = new OpenApiGenerator();
    List list = generator.getOperationList(anyModel);
    System.out.println(list);
}
 

开发者ID:networknt,
项目名称:light-codegen,
代码行数:8,
代码来源:OpenApiGeneratorTest.java

示例18: testInjectEndpoints

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Test
public void testInjectEndpoints() throws IOException {
    Any anyModel = JsonIterator.parse(SwaggerGeneratorTest.class.getResourceAsStream(openapiName), 1024).readAny();
    OpenApiGenerator generator = new OpenApiGenerator();
    generator.injectEndpoints(anyModel);
    System.out.println(anyModel.toString());
}
 

开发者ID:networknt,
项目名称:light-codegen,
代码行数:8,
代码来源:OpenApiGeneratorTest.java

示例19: testGenerator

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Test
public void testGenerator() throws IOException {
    Any anyConfig = JsonIterator.parse(SwaggerGeneratorTest.class.getResourceAsStream(configName), 1024).readAny();
    Any anyModel = JsonIterator.parse(SwaggerGeneratorTest.class.getResourceAsStream(swaggerName), 1024).readAny();

    SwaggerGenerator generator = new SwaggerGenerator();
    generator.generate(targetPath, anyModel, anyConfig);
}
 

开发者ID:networknt,
项目名称:light-codegen,
代码行数:9,
代码来源:SwaggerGeneratorTest.java

示例20: testGetOperationList

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Test
public void testGetOperationList() throws IOException {
    Any anyModel = JsonIterator.parse(SwaggerGeneratorTest.class.getResourceAsStream(swaggerName), 1024).readAny();
    SwaggerGenerator generator = new SwaggerGenerator();
    List list = generator.getOperationList(anyModel);
    System.out.println(mapper.writeValueAsString(list));
}
 

开发者ID:networknt,
项目名称:light-codegen,
代码行数:8,
代码来源:SwaggerGeneratorTest.java

示例21: testGeneratorWithSchema

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Test
public void testGeneratorWithSchema() throws IOException {
    Any anyConfig = JsonIterator.parse(GraphqlGeneratorTest.class.getResourceAsStream(configName), 1024).readAny();
    try(InputStream is = GraphqlGenerator.class.getResourceAsStream(schemaName)) {
        String schema = convertStreamToString(is);
        GraphqlGenerator generator = new GraphqlGenerator();
        generator.generate(targetPath, schema, anyConfig);
    }
}
 

开发者ID:networknt,
项目名称:light-codegen,
代码行数:10,
代码来源:GraphqlGeneratorTest.java

示例22: testGenerator

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Test
public void testGenerator() throws IOException {
    Any anyConfig = JsonIterator.parse(HybridServerGeneratorTest.class.getResourceAsStream(configName), 1024).readAny();

    HybridServerGenerator generator = new HybridServerGenerator();
    generator.generate(targetPath, null, anyConfig);
}
 

开发者ID:networknt,
项目名称:light-codegen,
代码行数:8,
代码来源:HybridServerGeneratorTest.java

示例23: testGenerator

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Test
public void testGenerator() throws IOException {
    Any anyConfig = JsonIterator.parse(HybridServiceGeneratorTest.class.getResourceAsStream(configName), 1024).readAny();
    Any anyModel = JsonIterator.parse(HybridServiceGeneratorTest.class.getResourceAsStream(schemaName), 1024).readAny();

    HybridServiceGenerator generator = new HybridServiceGenerator();
    generator.generate(targetPath, anyModel, anyConfig);
}
 

开发者ID:networknt,
项目名称:light-codegen,
代码行数:9,
代码来源:HybridServiceGeneratorTest.java

示例24: jsoniter

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Benchmark
@Override
public Object jsoniter() throws Exception {
    JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
    JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
    JsoniterAnnotationSupport.enable();

    ByteArrayOutputStream baos = JsonUtils.byteArrayOutputStream();
    JsonStream.serialize(JSON_SOURCE.nextPojo(), baos);
    return baos;
}
 

开发者ID:fabienrenaud,
项目名称:java-json-benchmark,
代码行数:12,
代码来源:Serialization.java

示例25: testGetGrouped

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Test
public void testGetGrouped() {
  String response =
      webTarget.path("v1/cubeName/last/120/group_by/field_name").request().get(String.class);
  APIResponse<Map<String, Map<String, Map<String, Map<String, Long>>>>> out =
      JsonIterator.deserialize(
          response,
          new TypeLiteral<
          APIResponse<Map<String, Map<String, Map<String, Map<String, Long>>>>>>() {});
  assertTrue(out.response.size() == 1);
}
 

开发者ID:cubedb,
项目名称:cubedb,
代码行数:12,
代码来源:CubeResourceTest.java

示例26: testInsert

点赞 2

import com.jsoniter.JsonIterator; //导入依赖的package包/类
@Test
public void testInsert() {
  List<DataRow> data = TestUtils.genSimpleData("cubeName", "p", "f", "c", 100);
  Entity<List<DataRow>> entity = Entity.entity(data, MediaType.APPLICATION_JSON_TYPE);
  String r = webTarget.path("v1/insert").request().post(entity, String.class);

  APIResponse<Map<String, Integer>> out =
      JsonIterator.deserialize(r, new TypeLiteral<APIResponse<Map<String, Integer>>>() {});
}
 

开发者ID:cubedb,
项目名称:cubedb,
代码行数:10,
代码来源:CubeResourceTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)