I have such string: [["9.00"],[ ],[ ],[ ],[ ]], ho...
# getting-started
s
I have such string: [["9.00"],[],[],[],[]], how do I turn it into list or array?
k
isn't the quotation marks inside a string needed to be skiped?
and does the empty brackets means `null`s ??
s
yes empty brackets must be nulls
k
and you need an array/list of Strings I suppose?
s
yeah
I have lots of strings like [["9.00"], ["11.00"], ["12.00"], ["9.00"], ["11.12", "14.14", "17.00"]] which must be turned either into list of lists or array of arrays, yet I don't have any idea how can this be done
b
using regex is probably the easiest
1
v
or a json parser
k
try
kotlinx.serialization
json library
🚫 1
a
Off the top of my head (I've not tried compiling this):
myString.split(",").map(if (it.contains("\")) {it.subStringAfter("\"").subStringBefore("\"")} else null)
k
@Sandm for example
[[1], [2], [3], ["11.12", "14.14", "17.00"]]
so I assume your list may contain lists like
{ 1, 2, 3, {11.2, 14.14, 17} }