All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.chargebee.internal.PrimitiveArrayParameter Maven / Gradle / Ivy

There is a newer version: 3.26.0
Show newest version
package com.chargebee.internal;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.Map;

public class PrimitiveArrayParameter extends Parameter {
    Integer index;
    public PrimitiveArrayParameter(String name, Integer index) {
        this.name = name;
        this.index = index;
    }
    @Override
    Map toFormURLEncoded(Map paramsMap) {
        paramsMap.put(name + "[" + index + "]", value);
        return paramsMap;
    }

    @Override
    JSONObject toJSONBody(JSONObject paramsJSON) {
        JSONArray existingArray = paramsJSON.opt(name) != null ? paramsJSON.optJSONArray(name) : new JSONArray();
        existingArray.put(index, value);
        paramsJSON.put(name, existingArray);
        return paramsJSON;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy