scala
[scala] org.json4s.package$MappingException: No usable value for xxx
'김용환'
2016. 10. 14. 11:11
scala의 json4s 사용시 아래와 같은 에러가 발생하면, 필드에 대한 오타가 발생했다.
Exception in thread "main" org.json4s.package$MappingException: No usable value for xxx
Did not find value which can be converted into java.lang.String
예를 들어, json source의 내용의 comment_type이고, case class은 comments_type으로 잘못 매핑 구조를 만들면, 에러가 발생한다.
예)
val source = """{"comment_type":"general"}"""
case class Comment(comments_type: String)
JsonMethods.parse(source).extract[Comment].comment_type