Class CollectionSerializer

java.lang.Object
com.postman.collection.adapter.CollectionSerializer
All Implemented Interfaces:
com.google.gson.JsonSerializer<Collection>

public class CollectionSerializer extends Object implements com.google.gson.JsonSerializer<Collection>
Custom serializer for the collection element. JSON does not require a particular order in order to be valid. However, Postman always outputs collections in the same order. This serializer replicates that order.
  • Constructor Details

    • CollectionSerializer

      public CollectionSerializer()
  • Method Details

    • serialize

      public com.google.gson.JsonElement serialize(Collection src, Type typeOfSrc, com.google.gson.JsonSerializationContext context)
      Specified by:
      serialize in interface com.google.gson.JsonSerializer<Collection>
      Parameters:
      src - The Collection passed in by Gson
      typeOfSrc - The Java Type of the object being parsed
      context - Serialization context passed in by Gson
      Returns:
      JsonElement The resulting Json