Git Product home page Git Product logo

Comments (4)

taowen avatar taowen commented on May 18, 2024

android 支持还要等一等,估计对于android来说最好是搞静态的代码生成。或者纯用反射。今天测了一下,纯反射仍然比jackson快一倍。

from java.

taowen avatar taowen commented on May 18, 2024

搞了一个静态代码生成的方案

https://github.com/json-iterator/java/blob/master/demo/src/main/java/com/jsoniter/demo/codegen/DemoCodegenConfig.java

执行后产生decoder的源代码。执行的目录应该是src/main/java的位置。然后使用的时候

https://github.com/json-iterator/java/blob/master/demo/src/main/java/com/jsoniter/demo/codegen/Demo.java

把执行模式切换为使用静态生成的decoder

JsonIterator.setMode(DecodingMode.STATIC_MODE);

这里的类是代码生成的:https://github.com/json-iterator/java/tree/master/demo/src/main/java/decoder

from java.

taowen avatar taowen commented on May 18, 2024
         <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.5.0</version>
                <executions>
                    <execution>
                        <id>static-codegen</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>java</executable>
                            <workingDirectory>${project.build.sourceDirectory}</workingDirectory>
                            <arguments>
                                <argument>-classpath</argument>
                                <classpath/>
                                <argument>com.jsoniter.StaticCodeGenerator</argument>
                                <argument>com.jsoniter.demo.codegen.DemoCodegenConfig</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

from java.

qiaokang avatar qiaokang commented on May 18, 2024

com.jsoniter.JsonException: must execute static code generator in the java source code directory which contains: main/java/com/jsoniter/demo/DemoCodegenConfig.java

不太理解这种方式,产生decoder的源代码的时候报上面的异常信息.有点蒙

from java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.