@Override
    public JsonElement serialize(final List<Element> elements, final Type typeOfSrc, final JsonSerializationContext context) {
        final JsonArray jsonArray = new JsonArray();
        int i = 0;
        for (Element element : elements) {
            final JsonObject elementJson = new JsonObject();
            elementJson.addProperty("name", element.getName());
            elementJson.addProperty("index", i);
            elementJson.addProperty("location", String.format(Locale.US, "%04X", element.getLocationDescriptor()));
            elementJson.add("models", serializeModels(context, element.getMeshModels()));

            jsonArray.add(elementJson);
            i++;
        }
        return jsonArray;
    }
Class for de-serializing a list of elements stored in the Mesh Configuration Database
mesh/src/main/java/no/nordicsemi/android/mesh/transport/InternalElementListDeserializer.java