Missing a JNumber-type in lift-json

5 views
Skip to first unread message

Andreas Joseph Krogh

unread,
Apr 12, 2021, 12:33:14 PM4/12/21
to Lift
Hi all.
 
Recently, browsers have started sending fraction-numbers as values for the JavaScript-types event.pageX and event.pageY. This leads to inconsistencies when parsing with code like this:
 
for {
   JInt(pageX) <- json \ "mouseCoordinates" \ "pageX"
   JInt(pageY) <- json \ "mouseCoordinates" \ "pageY"
} yield {...
...as this will fail for values with decimals, like 200.323221
 
Unfortunately parsing with JDouble doesn't always work either:
for {
   JDouble(pageX) <- json \ "mouseCoordinates" \ "pageX"
   JDouble(pageY) <- json \ "mouseCoordinates" \ "pageY"
} yield {...
 
as that fails when the client/browser sends the value as an Integer.
 
So - anyone knows what other frameworks do, when the value sent is "any number" (int or decimal)?
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963

Matt Farmer

unread,
Apr 12, 2021, 10:01:34 PM4/12/21
to lif...@googlegroups.com
Huh. I would expect JDouble to work and assume .0 - I would call that a bug. 

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/liftweb/VisenaEmail.0.590af0d37edb0363.178c6e746ff%40tc7-visena.
Reply all
Reply to author
Forward
0 new messages