• Some limitations of common JSON serialization tools in Java


    Problem When writing Java unit test, the expected value of unit test is usually obtained fromtest/resourcesIn the directory, the expectresult.json is read in and deserialized with the JSON serialization tool to get the expected result of the unit test, and compared with the actual result of the test. However, if the class used for deserialization […]

  • Gson and List Objects’Matching Tour


    With the improvement of people’s living standard, the channel of matchmaking between people has been further improved. Recently, I occasionally saw several variety shows of dating, whether civilians or stars. It can be seen that the tide of matchmaking is coming. That’s not why two old guys, Google and Java, can’t sit still, thinking that […]

  • Gson parsing Json fault tolerance is the key, to cite a few common examples!


    I. Preface A few days ago, I wrote an article about data fault tolerance between JSON serialization and deserialization using GSON. The simplest [email protected] to configure multiple different JSON Key values, or to reuse [email protected] configure some exceptions. More complex data can be solved by using Type Adapter, which can be said to be a […]

  • Gson Conversion-json Data Conversion to Object Entity Common Method


    Gson Conversion-json Data Conversion to Object Entities Recently, when making remote interface calls, data needs to be encrypted and decrypted, so the parameters returned are uniformly in the following JSON format { “code”:0, “Msg”, “Success”. “sign”:”abcdefghijkl”, “timestamp”:1491897441000, “data”:{} } First, we assume that the object entities in the transmission process are user.java public class User […]

  • Gson – Compare two order-independent JSON strings


    Gson – Compare two order-independent JSON strings When map data is converted to json, JSON output is out of order because map is out of order.When we compare the two jsons, we need to ignore their order of comparison. The methods of comparison are as follows: Assuming that we have ID and name in our […]