martyix
08/21/2017, 5:31 AMval command = """{"type":"Modify", "content":{"levels": { "$identifier": {"$propertyName":"$value"}}}}"""
This is obviously very bad code as any of the variables can easily break JSON. What would be "kotlin-way"? I'm looking for some concise solution. 🙂 Thanks
PS: I use Kotlin 1.1.4karelpeeters
08/21/2017, 7:34 AMfun String.escape() = this.replace('\t', "\\t").replace('\n',"\\n")...
, see this for everything you need to replace: https://www.freeformatter.com/json-escape.htmlval command = {"type":"Modify", "content":{"levels": { "${identifier.escape()}": {"${propertyName.escape()}":"${value.escape()}"}}}}