code: public static @Nonnull JsonArray lineStringToPolygon(@Nonnull JsonArray lineString) {
          if(!lineString.first().equals(lineString.last())) {
              JsonElement e = lineString.first().deepClone();
              lineString.add(e);
          }
          return array(lineString);
      }
docs: Takes a two dimensional linestring and creates a three dimensional polygon from it. Also closes the polygon if needed.
  @param lineString 2d JsonArray
  @return 3d double array with the polygon