Я передаю и полезную нагрузку, которая похожа на case class reportdata
, внутри класса. И мне нужно, чтобы получить значение report_data
, которое является Option [JSArray],
Мне нужно назначить этот JSArray для переменной, если этот необязательный массив соответствует case class reportdata
case class Fields(
reportid: Option[Long],
report_data: Option[JsArray],
header :Option[JsArray],
footer :Option[JsArray]
)
case class reportdata(
customText : Option[String],
textAlignment: Option[String],
textSize : Option[Int],
pageHeight: Long,
pageWidth: Long
)
Json, который я передаю из БД, относится к типу полей класса Fields и имеет 3 JSON массива. поэтому я хочу выбрать массив json, соответствующий классу данных отчета, и я должен назначить его новой переменной.
"reports": [
{
"reportid":513,
"report_data":[
{
"formatType": "text",
"value": "This is a sample text to be printed in the report"
},
{
"formatType": "text size",
"value": 12
},
{
"formatType": "text alignment",
"value" : "RIGHT"
},
{
"formatType": "page height",
"value" : "12"
},
{
"formatType": "page width",
"value" : "8"
}
],
"header": [
{
"formatType": "text",
"value": "Test"
},
{
"formatType": "font size",
"value": 12
}
],
"footer": [
{
"formatType": "text",
"value": "Test"
},
{
"formatType": "font size",
"value": 12
}
]
}
]