JSONObject jsonFormatter(String content, Boolean isCategorie) throws JSONException {

    JSONObject mData = new JSONObject(content);

    JSONObject header = new JSONObject(mData.opt("header"));
    Map<Integer, String> propertyIndexes, elementIndexes;
    Map<String, Object> itemsObject;
    List<Map<String, Object>> items = new ArrayList<>();

    elementIndexes = parseIndexes(header, "elementIndex");
    propertyIndexes = parseIndexes(header, "propertyIndex");

    JSONArray values = mData.optJSONArray("values");

    for (int i = 0; i < values.length(); i++) {
      JSONArray value = values.getJSONArray(i);

      itemsObject = new HashMap<String, Object>();

      Map<String, Object> propertiesObject = new HashMap<String, Object>();

      for (int j = 0; j < value.length(); j++) {

        if (propertyIndexes.containsKey(j)) {
          itemsObject.put(propertyIndexes.get(j), value.optString(j));

        } else if (elementIndexes.containsKey(j)) {

          propertiesObject.put(elementIndexes.get(j), value.optString(j));
        } else {
          break;
        }

        if (!elementIndexes.isEmpty()) {
          itemsObject.put("properties", propertiesObject);
        }
      }

      items.add(itemsObject);
    }

    String listofProperties = mData.optString("listProperties");
    JSONObject tmp;
    if (listofProperties == null || listofProperties.isEmpty()) {
      tmp = new JSONObject();
    } else {
      tmp = new JSONObject(listofProperties);
    }
    if (isCategorie) {
      tmp.putOnce("items", new JSONArray(items));
    } else {

      tmp.putOnce("item", new JSONArray(items));
    }

    return tmp;
  }