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 […]

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 […]