cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

The case class reports an error when running in the notebook

้ฝๆœจๆœจ
New Contributor III

image.pnglocalimageAs shown in the figure, the case class and the json string are converted through fasterxml.jackson, but an unexpected error occurred during the running of the code. I think this problem may be related to the loading principle of the notebook. Because of the same code, I get the correct result when I run it on my local computer

1 ACCEPTED SOLUTION

Accepted Solutions

้ฝๆœจๆœจ
New Contributor III

code๏ผš

var str="{\"app_type\":\"installed-app\"}"
    import com.fasterxml.jackson.databind.ObjectMapper
    import com.fasterxml.jackson.module.scala.DefaultScalaModule
    val mapper = new ObjectMapper()
    mapper.registerModule(DefaultScalaModule)
    val rmodel=mapper.readValue(str, classOf[appDeeplink])
    println(rmodel)
import com.fasterxml.jackson.annotation._
 
 
@JsonIgnoreProperties(ignoreUnknown = true)
case class appDeeplink(
                        @JsonProperty("app_type") app_type: String
                      ) 

โ€‹

View solution in original post

1 REPLY 1

้ฝๆœจๆœจ
New Contributor III

code๏ผš

var str="{\"app_type\":\"installed-app\"}"
    import com.fasterxml.jackson.databind.ObjectMapper
    import com.fasterxml.jackson.module.scala.DefaultScalaModule
    val mapper = new ObjectMapper()
    mapper.registerModule(DefaultScalaModule)
    val rmodel=mapper.readValue(str, classOf[appDeeplink])
    println(rmodel)
import com.fasterxml.jackson.annotation._
 
 
@JsonIgnoreProperties(ignoreUnknown = true)
case class appDeeplink(
                        @JsonProperty("app_type") app_type: String
                      ) 

โ€‹

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.