1

I would like to serialise this to a JSON string:

private Map<Variant, Map<Integer, ItemStack>> inventorySorting;

I tried to use new TypeToken<Map<Variant, Map<Integer, ItemStack>>>(){}.getType())); But i got this exception: enter image description here

Michał Ziober
  • 37,175
  • 18
  • 99
  • 146
f1fty
  • 21
  • 3
  • 1
    It looks like you have circular references between your objects. You need to add to your question how thew two classes are implemented. See: [GSON: how to prevent StackOverflowError while keeping circular references?](https://stackoverflow.com/questions/14489463/gson-how-to-prevent-stackoverflowerror-while-keeping-circular-references) and [How to solve circular reference in json serializer caused by hibernate bidirectional mapping?](https://stackoverflow.com/questions/3340485/how-to-solve-circular-reference-in-json-serializer-caused-by-hibernate-bidirecti) – Michał Ziober Mar 16 '19 at 00:25
  • 1
    Please add a [MCVE](https://stackoverflow.com/help/mcve) – Bohemian Mar 16 '19 at 01:10

0 Answers0