简体   繁体   中英

Scala case class to convert to jsonObject

I have a case class object, and I want to convert this object to JsonObject (not JsonString ) using ( com.fasterxml.jackson which is Java API) but the output I got is {} , which is not expected.

How I solved is :

I wrote a Scala Pojo class (How we write in Java with getter and setter, may be not correct way to write Pojo in Scala, as my knowledge in Scala is very minimal.) which solved the problem, and got proper jsonObject .

Do any one of you know better solution other than this?

If you are using Play framework, then have a look here:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM