A support library for integrating JSON API specification with Scala and Spray JSON
@zmeda curious if this has come up in your work with scala + jsonapi. they talk about queryParams like ?field=1&nested[field]=2&nested[fields][]=3&nested[fields][]=4
and they’re supposed to be deserialized to
{field: 1, nested: {field: 2, fields: [3,4]}}
rails and sinatra both handle that automatically, but i haven’t found anything like that for scala or java, have you?
i think i’m passed the point of diminishing returns for the day anyway :tired_face: https://github.com/RavelLaw/scala-jsonapi/tree/scala-2.12 if anybody else wants to chime in and see if that’s reasonable so far.
i’ll wait on #64 then take another stab after some time away
some thoughts from today
seems like, with spray going away, the akka http stuff should just be one level above the core and not depend on spray.
so the dependency graph i’d think should be like
models and implicits no external libs (seems like that’s already on track)
would have maybe somethings to the effect of
// no real need for the `AkkaHttp` prefix since `spray-http` will be gone and everything is targeting the `akka-http` `HttpEntity`s now
trait JsonapiSupport[Model] {
implicit def stringToRootObject(string: String): RootObject = ???
implicit def rootObjectToString(rootObject): String = ???
//internal dependent json projects would implement the above
def modelToRootObject(from: Model): RootObject = ???
def modelFromRootObject(rootObject: RootObject): Model = ???
//external clients would implement the above in with whatever (de)serialization stuff they like
implicit def jsonApiObjectWriter = new JsonApiObjectWriter[Model] {
override toRootObject(model: Model) = modeToRootObject(model)
}
implicit def jsonApiObjectReader = new JsonApiObjectReader[Model] {
override fromRootObject(rootObject: RootObject) = modeFromRootObject(rootObject)
}
// the following can be implemented using the preceding but more than i can do off the top of my head right now :sweat_smile:
implicit def modelMarshaller: ToEntityMarshaller[Model] = ???
implicit def modelUnmarshaller: FromEntityMarchaller[Model] = ???
these guys then would essentially just be de/serializing strings to/from RootObjects using their respective json impls