0

I'm new to Scala. I have a string as below

2017-07-07|{"success":true,"data":{"status":"200","message":"Operation completed."}}

I only need the second part of the string. I'm able to using map and split it into string as below

{"success":true,"data":{"status":"200","message":"Operation completed."}}

but it's suppose to be JSON, and I'm not able to parse it. Hope someone can give me some guide.

jwvh
  • 50,871
  • 7
  • 38
  • 64
hpkong
  • 42
  • 6

1 Answers1

0
val y = "2017-07-07|{\"success\":true,\"data\":{\"status\":\"200\",\"message\":\"Operation completed.\"}}"
val res = y.split('|')(1)

as for JSON serialization you can use lift_json as it can be used independent, just add the dependency to your SBT file and then use the following code to parse the string

import net.liftweb.json._
parse(res)
Saddam Abu Ghaida
  • 6,381
  • 2
  • 22
  • 29