目前我有这个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
。有人可以告诉我该怎么做吗?
答案 0 :(得分:0)
也许您可以在以下答案中使用反射:
正如他们在答案中所说,如果您可以避免使用反射并尝试直接拥有阵列,请不要犹豫(反射会带来性能问题)。
答案 1 :(得分:0)
将对象转换为String(.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));
这不是完美的答案,但可能会对您有所帮助