Definition ? Gson Gson is a Java serialization/deserialization library for converting Java objects to JSON format and converting JSON format back to Java objects. ? Moshi Moshi is a modern JSON library for Android and Java. It makes it simple to parse JSON into Java objects and convert Java objects back to JSON. ? Kotlin […]
Tag: gson
Moshi Vs Gson Vs Kotlin Serialisation performance PK
Moshi Vs Gson Vs Kotlin Serialisation Definition Gson Gson is a Java serialization/deserialization library for converting Java objects to JSON format and converting JSON format back to Java objects. Moshi Moshi is a modern JSON library for Android and Java. It makes it simple to parse JSON into Java objects and convert Java objects back […]
Loongson 2K500 Pioneer boardLight up RGB colorful light-emitting board
Article directory 1. Hardware preparation 1.1 DFRobot RGB colorful light emitting board 1.2 Loongson 2K0500 development board 2. Background knowledge 3. Realize lighting 3.1 Manual lighting 3.2 Turn off manually 3.3 Realize PwmController 3.4 Realize the effect of breathing light 4. Effect demonstration Five, complete code 6. Reference link Some time ago, Qiao Gang sent […]
Gson and Kotlin’s old-fashioned empty safety issues
A problem occurred I accidentally found an NPE that should not appear in a debug. Take the following simplified example as an example: Exception in thread “main” java.lang.NullPointerException: Cannot invoke “kotlin.Lazy.getValue()” because “<local1>” is null The corresponding data model is as follows: class Book( val id: Int, val name: String? ) { val summary by […]
Mutual conversion between java and json_Jackson_Gson_Fastjson
Log overview In daily practice, JSON data and Java objects are usually mutually converted. The conversion requires the use of a JSON parser. The common parsers are as follows: Jsonlib (JSON official) Gson (Google) Jackson (Spring Official) Fastjson(Alibaba) If it is developed as a Spring MVC / SpringBoot technology stack, it is best to use […]
Gson: An excellent tool to make Java and JSON fall in love with each other
Introduction JSON (JavaScript Object Notation) is a lightweight data exchange format that is easy to read and write, as well as easy for machines to parse and generate. In Java projects, JSON is widely used in various scenarios, such as data transfer, configuration files, logging, etc. in web applications. With the increasing demand of Java […]
Use Gson to parse Json data
Directory 1. Introduction to Gson 2. How to use Full code: MainActivity: layout: operation result: 1. Introduction to Gson Gson is a Java library provided by Google for converting Java objects into JSON format data or converting JSON format data into Java objects. Common methods: Method name Function toJson(Object src) Convert the object into corresponding […]
Moshi perfectly solves the problem of empty default value of Gson in kotlin in the true sense
Moshi Moshi is a Json library that is more friendly to Kotlin, square/moshi: A modern JSON library for Kotlin and Java. (github.com) Depends implementation(“com.squareup.moshi:moshi:1.8.0”) kapt(“com.squareup.moshi:moshi-kotlin-codegen:1.8.0”) Usage scenario Reflection based on kotlin-reflection requires additional com.squareup.moshi:moshi-kotlin:1.13.0 dependency // generateAdapter = true means use codegen to generate the JsonAdapter of this class @JsonClass(generateAdapter = true) // @Json identifies […]
Moshi perfectly solves the problem of Gson’s default value being empty in kotlin in the true sense
Moshi Moshi is a Json library that is more friendly to Kotlin, Depends implementation(“com.squareup.moshi:moshi:1.8.0”) kapt(“com.squareup.moshi:moshi-kotlin-codegen:1.8.0”) Usage scenario Reflection based on kotlin-reflection requires additional com.squareup.moshi:moshi-kotlin:1.13.0 dependency // generateAdapter = true means use codegen to generate the JsonAdapter of this class @JsonClass(generateAdapter = true) // @Json identifies the field name in json data class Person(@Json(name = “_name”)val […]
Performance comparison of JSON libraries: JSON.simple VS GSON VS Jackson VS JSONP
My personal Texas Hold’em project https://github.com/mingzijian/pokers, welcome to give stars. Reprinted from http://www.open-open.com/lib/view/open1434377191317.html Which JSON library in Java has the fastest parsing speed? JSON has become the accepted standard for data transmission between the current server and WEB applications, but like many things we are used to, you will take it for granted and stop […]