cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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
                      ) 

โ€‹

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group