如果我有JSON
{"name":"jack","email":"jackt@gmail.com"}
现在在映射此JSON时,我只希望在案例类中映射名称,例如
case class Person(name:String)
我们如何实现这一目标?
答案 0 :(得分:0)
import spray.json._
case class Person(name: String)
object PersonFormat extends DefaultJsonProtocol {
implicit val personFormat = jsonFormat1(Person)
}
import PersonFormat._
val source = """{ "name":"jack", "email":"jackt@gmail.com" }"""
source.parseJson.convertTo[Person]
您需要使用隐式val定义JsonProtocol。
答案 1 :(得分:-2)
With ActiveWorkbook.ActiveSheet.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("D3:D" & XY), Order:=xlAscending
.SortFields.Add Key:=Range("C3:C" & XY), Order:=xlAscending
.SortFields.Add Key:=Range("E3:E" & XY), Order:=xlAscending, CustomOrder:="Team1, Team5, Leader, Team3, Team10"
.SetRange Range("A3:" & CC2 & XY)
.Header = xlNo
.Apply
End With
您的姓名将被映射为忽略电子邮件。
在这里查看小提琴:https://scalafiddle.io/sf/9nppAtI/0