Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.nubeiot.dsl
- import spray.json.{DefaultJsonProtocol, JsValue}
- object JsonStuff {
- case class Response(items: Seq[Thing])
- case class Thing(thingId: String, features: Features)
- case class Features(histories: Histories)
- case class Histories(properties: Map[String, History])
- case class History(data: Seq[Value])
- case class Row(thingId: String, point: String, time: Long, value: Double)
- case class Value(ts: Long, `val`: JsValue) {
- def value = `val`.toString.filterNot(c => c == '"' || c == '\\').toDouble
- }
- object MyJsonProtocol extends DefaultJsonProtocol {
- implicit val valueFormat = jsonFormat2(Value)
- implicit val historyFormat = jsonFormat1(History)
- implicit val historiesFormat = jsonFormat1(Histories)
- implicit val featuresFormat = jsonFormat1(Features)
- implicit val thingFormat = jsonFormat2(Thing)
- implicit val responseFormat = jsonFormat1(Response)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement