简体   繁体   中英

Array of associate arrays in JAVA

  $postfields["pricing[1][annually]"] = "50.00";
  $postfields["pricing[1][monthly]"] = "50.00";
  $postfields["pricing[2][monthly]"] = "8.00";
  $postfields["pricing[2][annually]"] = "80.00";

I want something similar to the above variable in java. I am not talking about creating a class with required variables.

I have used List<Map<String,String>> pricing = new ArrayList<Map<String,String>>(); but that doesn't seem to work with WHMCS api.

I debugged and came across this value on the back-end

 "pricing" -> "[{monthly=5.00, annually=50.00}]"

That is how it is done in the api:

http://docs.whmcs.com/API:Add_Product

Do we have anything similar in java that can cater this issue? I am integrating a billing solution with WHMCS using their api.

You can use a simple 2D double array. You'll create some int constants for annually = 0, monthly = 1

double pricing = new double[][]{50.0, 50.0};

and so on

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM