Github user yanboliang commented on a diff in the pull request: https://github.com/apache/spark/pull/19525#discussion_r155412287 --- Diff: mllib/src/main/scala/org/apache/spark/ml/param/params.scala --- @@ -122,17 +124,33 @@ private[ml] object Param { /** Decodes a param value from JSON. */ def jsonDecode[T](json: String): T = { - parse(json) match { + val jValue = parse(json) + jValue match { case JString(x) => x.asInstanceOf[T] case JObject(v) => val keys = v.map(_._1) - assert(keys.contains("type") && keys.contains("values"), - s"Expect a JSON serialized vector but cannot find fields 'type' and 'values' in $json.") - JsonVectorConverter.fromJson(json).asInstanceOf[T] + if (keys.contains("class")) { + implicit val formats = DefaultFormats + val className = (jValue \ "class").extract[String] + className match { + case JsonMatrixConverter.className => + val checkFields = Array("numRows", "numCols", "values", "isTransposed") --- End diff -- Should we check _type_ as well?
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org