Play ScalaJSON Reads[T] parsing ValidationError(error.path.missing,WrappedArray())

前端 未结 1 2053
再見小時候
再見小時候 2020-12-17 15:42

i have a funny json data looking as:

[ {
  \"internal_network\" : [ {
    \"address\" : [ {
      \"address_id\" : 2,
      \"address\" : \"172.16.20.1/24\"
         


        
相关标签:
1条回答
  • 2020-12-17 16:10

    The error is telling you that instead of /switch_id it got an array. So it seems like you should read the JSON as a List[Switch] instead of just Switch

    Assuming your Reads (didn't test them) are correct this should work:

    val json: JsValue = Json.parse(jsonChunk)
    println(json.validate[List[TheSwitch]])
    
    0 讨论(0)
提交回复
热议问题