json - json4s object extraction with extra data -


I am using spray with json4s, and to handle items placed to update items, Implementation is found ... My problem with it is that I first used an example of some objects from JSN, but being a cool API, I want to specify an ID in the URL. Then I have to make another example of some object which is indexed with ID ... To do this, I am using a constructor like some object (id: long, obg: some object). It works well, but the implementation is ugly and it seems unworthy. What can I do so why can I paste the ID in some way so that I can make an example of only some objects?

class ApplicationRouter extends BaseRouter {val routes = pathPrefix ("some-path") {path ("destination resource" \ intNumber) {id = & gt; Entity (as [Jobic]) {rawData = & gt; Some ExtractedObject = rawData.camelizeKeys.extract [SomeObject] Val ExtractedObjectWithId = SomeObject (ID, extractedObject) handleRequest (extractedObjectWithId)}}}} Case class SomeObject (id: long, data: string, someValue: double, someDate: DATETIME) {def This (data: string, someValue: double, someDate: DATETIME) = this (0, data, someValue, someDate) def (id: long, obj: someObject) = this (id, obj.data, obj.someValue, obj .someDate)}

I find a solution for this around through docs For a while after digging on behalf:

  ApplicationRouter BaseRouter {val = routes PathPrefix ( "a path") {path ( "destination resources" \ IntNumber) {id = & gt extends entity (as [Jobik]) {rawData = & gt; Value extractedObject = rawData.camelizeKeys.merge {("id", id)} .extract [SomeObject] handleRequest (extractedObject)}}}  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -