Ink
10/27/2022, 9:11 AMid: 123, price: 29,99, isAvailable: true
I try to get value of those variables:
val object= string.trim().removeSurrounding("{", "}").split(",").map {
it.split(":")[1].trim()
}
val id = productString[0]
val price = productString[1]
val isAvailable= productString[2].toBooleanOrNull()
The problem is price
. It cointains ,
between 29 and 99 and it makes error. How I can avoid dividing price on two parts in that case? I don't want to use .
instead of ,
Steve Georgakis
10/27/2022, 9:13 AM.
is the standard for decimals. if you really need to use ,
, then you should pass it as a string. also, a json parsing library would probably be more convienientSam
10/27/2022, 9:15 AMsplit
from split(",")
to split(", ")
(with an additional space after the comma). That will work if you can be sure that commas between entries will always be followed by a space.Ink
10/27/2022, 9:25 AMephemient
10/27/2022, 9:58 AMJoffrey
10/27/2022, 9:59 AM