鸿蒙开源组件——JSON解析和序列化库

发布于 2021-11-9 17:37
浏览
0收藏

LoganSquare

适用于ohos的最快的JSON解析和序列化库。LoganSquare基于Jackson的流API,能够始终胜过GSON和Jackson的Databind库400%或更多1。通过依靠编译时注释处理来生成代码,您知道JSON的解析和序列化速度比任何其他可用方法都快。

通过使用此库,您将能够利用Jackson的流API的功能,而不必编写tedius(涉及JsonParsers或JsonGenerators的底层代码)的代码。相反,只需将模型对象标记为a @JsonObject,将字段注释为@JsonFields,我们将为您完成繁重的工作。

图片鸿蒙开源组件——JSON解析和序列化库-开源基础软件社区

鸿蒙开源组件——JSON解析和序列化库-开源基础软件社区

引入

通过DevEco studio 2.0+,并下载SDK Native 版本2.0+ 方式一: 在entry的gradle中集成如下操作:

如果使用har,请将har放到entry中的libs

修改implementation fileTree(dir: 'libs', include: ['.jar','.har'])增加*.har 如果是jar包请加上

compile files('libs/processor.jar')
annotationProcessor files('libs/processor.jar')

无需关注:由于在JavaLibrary需要引入三方库,但是打jar的时候三方库无法打到包中,于是用了一个笨的方法,扒了源码在里面,如果您想研究源码看到library中com文件夹下有fasterxml,squareup两个文件夹请忽略。

方式二:

allprojects{
    repositories{
        mavenCentral()
    }
}
implementation 'io.openharmony.tpc.thirdlib:logansquare:1.0.3'
annotationProcessor 'io.openharmony.tpc.thirdlib:logansquare:1.0.3'

用法

使用LoganSquare变得非常容易。以下是一些入门文档:

entry运行要求

通过DevEco studio,并下载SDK 将项目中的build.gradle文件中dependencies→classpath版本改为对应的版本(即你的IDE新建项目中所用的版本)

License

/*----------------------------------------------------------------------------

  • Copyright (c) <2013-2018>, <Huawei Technologies Co., Ltd>
  • All rights reserved.
  • Redistribution and use in source and binary forms, with or without modification,
  • are permitted provided that the following conditions are met:
    1. Redistributions of source code must retain the above copyright notice, this list of
  • conditions and the following disclaimer.
    1. Redistributions in binary form must reproduce the above copyright notice, this list
  • of conditions and the following disclaimer in the documentation and/or other materials
  • provided with the distribution.
    1. Neither the name of the copyright holder nor the names of its contributors may be used
  • to endorse or promote products derived from this software without specific prior written
  • permission.
  • THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  • "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  • THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  • PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  • CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  • EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  • PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  • OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  • WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  • OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  • ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------/ /*----------------------------------------------------------------------------
  • Notice of Export Control Law
  • ===============================================
  • Huawei LiteOS may be subject to applicable export control laws and regulations, which might
  • include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
  • Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
  • applicable export control laws and regulations. ---------------------------------------------------------------------------/

LoganSquare-master.zip 1.77M 9次下载
已于2021-11-9 17:37:21修改
收藏
回复
举报
回复
添加资源
添加资源将有机会获得更多曝光,你也可以直接关联已上传资源 去关联
    相关推荐