目前我有这个object
:
CurrencyType(Stuff1=null, Stuff2=0.61952, Stuff3=1.2117, Stuff4=2.9687, Stuff51=0.95025, Stuf6=0.69852, Stuff7=4.9222, Stuff8=15.931, Stuff9=4.6196, Stuff10=0.55648, Stuff11=5.6577, Stuff12=4.6056, Stuff13=202.27, Stuff14=10732.0, Stuff15=2.5838, Stuff16=51.865, Stuff17=79.175, Stuff18=80.258, Stuff19=808.33, Stuff20=13.856)
因为我想在Recycler View
中显示这个结果而且JSON没有给我一个Array
我需要将这些值分成Array
。有人可以告诉我该怎么做吗?
也许你可以在这些答案中使用反射:
正如他们在答案中所说,如果您可以避免使用反射并尝试直接使用阵列,请不要犹豫(反射会引发性能问题)。
将对象转换为字符串(.toString())
String datam="CurrencyType(Stuff1=null, Stuff2=0.61952, Stuff3=1.2117, Stuff4=2.9687, Stuff51=0.95025, Stuf6=0.69852, Stuff7=4.9222, Stuff8=15.931, Stuff9=4.6196, Stuff10=0.55648, Stuff11=5.6577, Stuff12=4.6056, Stuff13=202.27, Stuff14=10732.0, Stuff15=2.5838, Stuff16=51.865, Stuff17=79.175, Stuff18=80.258, Stuff19=808.33, Stuff20=13.856)";
String[] arr_one=datam.replace("CurrencyType(","").replace(")","").split(",");
List<String> stringList = new ArrayList<String>(Arrays.asList(arr_one));
这不是完美的答案,但它可能会帮助你