1.15.2 What is best way to serialize inventory with items and save it as text into SQLite row?

Discussion in 'Spigot Plugin Development' started by Msql, Feb 13, 2020.

  1. What is best way to serialize inventory with items and save it as text into SQLite row?
    I am creating "transmutators" plugin and I need whole inventory to be serialized as text to database.

    Thanks for any help!
     
  2. So doing something like this
    Code (Java):
    ByteArrayOutputStream str = new ByteArrayOutputStream();
    BukkitObjectOutputStream data = new BukkitObjectOutputStream(str);
    data.writeObject(itemstack);
    String base64 = Base64.getEncoder().encodeToString(str.toByteArray());
    should be best?
    I see it is also Serializable (without any config) but I am asking for best way :p
     
  3. heard Apache Avro does the job the best
     
  4. I do not understand how it works. Can you give example code, please :x?
     
  5. Gson should also be considered as an option.