J'ai un problème analyse JSON dans RDDJSON-Scala - Liste Parse
{ "data": "{\" orderID \ ": \" 3 \ "\ "produits \": [{\" productID \ ": 10028, \" category \ ": \" 342 \ ", \" name \ ": \" Enfants Manteaux \ ", \" genre \ ": \" Enfants \ ", \" sport \ ": \" Basketball \ ", \" color \ ": \" Bleu \ ", \" retailPrice \ ": 268.0, \" sellPrice \ ": 268.0, \" sellQuantité \ ": 1, \" taxablePrice \ ": 268.0, \" marque \ ": \" Inno Fashion \ ", \" stockQuantité \ ": 999, \" sous-total \ ": 268.0, \" ancesstorCategories \ ": [\" 2426 \ ", \" 2454 \ ", \" 241 \ "," 342 "," 24 "," 34 "," 2439 "," 21 "," 3 "," 2 "," 1 ", \ "2412 \", \ "2430 \", \ "2503 \"]}, {\ "productID \": 10031, \ "catégorie \": \ "334 \", \ "nom \": \ "Enfants Tshirt \ ", \" genre \ ": \" Enfants \ ", \" sport \ ": \" Cyclisme \ ", \" couleur \ ": \" Bleu \ ", \" retailPrice \ ": 59.0, \" sellPrice \ ": 59.0, \" sellQuantity \ ": 6, \" taxablePrice \ ": 59.0, \" brand \ ": \" 361 Sports \ ", \" stockQuantité \ ": 994, \" sous-total \ ": 354 . 0, \ "ancesstorCategories \": [\ "2426 \", \ "241 \", \ "33 \", \ "24 \", \ "2429 \", \ "334 \", \ "2439 \" , "21", "3", "2", "1", "2412", "2503", "2451" "")
J'ai lu ces informations dans RDD,
1. val content = parse(event.properties.get[String]("data"))
2. val productID = (for {JInt(x) <- (content \\ "productID")} yield x.toString())
3. val sellProductQuantity = (for {JInt(x) <- (content \\ "sellQuantity")} yield x.toString())
4. val category = for { JArray(x) <- (content \\ "ancesstorCategories")} yield x
5. val compactProductId = compact(content \\ "productID")
6. yield BuyEvent(
7. user = userID,
8. item = productID(index).toString,
9. category = category(index),
10. count = (sellProductQuantity(index).values.toString).toInt)
Je suis une erreur à la ligne 9, lors du traitement de la catégorie Je voudrais obtenir le « ancestorCategories » de JSON dans la « catégorie » ou RDD comme une liste liste (2426, 2454, 241, 342, 24, 34, 2439, 21, 3, 2, 1, 2412, 2430, 2503)
Erreur: trouvée: [org.json4s.JsonAST.JValue] [ERROR ] [Console $] [error] required: Array [String]
Quelqu'un peut-il m'aider à convertir List [org.json4s.JsonAST.JValue] en List [String]? Merci beaucoup.
ce que jamais vous pouvez en x => {} Personne ne peut comprendre votre code. Même erreur que dans votre post précédent: le code ne compile pas, le code n'est pas bien formaté et indenté, aucune importation donnée. Modifier en conséquence! –
également posté à https://groups.google.com/d/msg/scala-user/bqsYqN4s0So/MtIlOibqBwAJ –