0

I am working in Scala programming language.

I want to convert json object to Map[String, String]

My jsonObject looks like

{"Key1":"Val1","Key2":"Val2","Key3":"Val3"}

I want to have a Map like

Map("Key1" -> "Val1", "Key2" -> "Val2", "Key3" -> "Val3")

How can i do this? Note: I am using Gson for my other json manipulation

Thanks

user10360768
  • 225
  • 3
  • 14
  • There are tons decoders in scala. I like [circe](https://circe.github.io/circe/) a lot they have a nice documentation as well. Also look st this please [arse get request to jsonarray in Scala](https://stackoverflow.com/a/50651708/432903) and [Pretty JSON multi reg to one line JSON multi reg](https://stackoverflow.com/a/50219457/432903) – prayagupa Nov 09 '18 at 00:35
  • are you also using java or purely scala if you're using gson? – joel Nov 09 '18 at 08:18
  • likely a dup of https://stackoverflow.com/q/2779251/5986907 or https://stackoverflow.com/q/8054018/5986907 – joel Nov 09 '18 at 08:21
  • I solved it using JSON.parseFull(dataString) – user10360768 Nov 09 '18 at 23:14

1 Answers1

2

You can use Jackson object Mapper for this.

https://www.alexkras.com/parse-json-object-to-map-in-scala-using-jackson/

Himanshu
  • 164
  • 4