This is a tricky one. The problem with extending the AST is that the AST is implemented as an algebraic data type. And by definition it is not possible to extend such a type.
One way to add BSON support is to create a new AST for it which includes all extended literals. Then add a few core functions for that ADT (map, etc.) and maybe a function which can encode BSON as JSON (bvalue.toJson). Encoding BSON as JSON would give some features for free, for instance toXml. Anyway, this approach would probably cause some code duplication between lift-json and lift-bson. Converting the JSON AST to an object oriented design would be another approach. Then adding new AST nodes would not be a problem. But that would be a huge change to the lib. Probably too big at this phase. Since BSON is a superset of JSON we could refactor current lift-json to be lift-bson and then implement lift-json on top of it. On a cursory look this feels cleanest but there might be some performance penalties for normal JSON processing due to conversions. To be honest, I'm not yet sure what would be the best approach. Cheers Joni On Mar 5, 10:08 pm, Ross Mellgren <dri...@gmail.com> wrote: > The JSON stuff is mostly just an AST and encoding/decoding from the JSON wire > format is almost just an addon. Then, it would be a matter of adding AST > objects for those new things. Could be a use for phantom types ;-) > > I'd be interested to hear Joni's view on how it might fit, since he's the > most familiar. > > -Ross > > On Mar 5, 2010, at 1:26 PM, Tim Nelson wrote: > > > I definitely agree with keeping the BSON code separate or possibly > > having a strict JSON mode. > > > Tim > > > On Fri, Mar 5, 2010 at 12:13 PM, Timothy Perrett > > <timo...@getintheloop.eu> wrote: > >> Probably a sub-ordinate module would be preferable... one that builds on > >> the lift-json stuff and doesn't pollute the "normal" JSON usage. > > >> Joni, what are your thoughts? > > >> Cheers, Tim > > >> On 5 Mar 2010, at 17:59, Tim Nelson wrote: > > >>> I finally had the opportunity to look into the couchdb code and I must > >>> say it is rather impressive. > > >>> I would like to utilize the code in JSONRecord.scala in scamongo [1]. > >>> However, MongoDB uses a variation of JSON they call BSON, which they > >>> actually just published a spec [2] for, due to interest outside of > >>> MongoDB. Basically, it adds support for date, ObjectId [3], binary > >>> data, regular expressions, and code (JavaScript) data types. > > >>> My question is, what would it take to add support to lift-json for > >>> these other data types? Is this even feasible? > > >>> Thanks, > >>> Tim > > >>> [1]http://github.com/eltimn/scamongo > >>> [2]http://bsonspec.org/ > >>> [3]http://www.mongodb.org/display/DOCS/Object+IDs > > >>> -- > >>> You received this message because you are subscribed to the Google Groups > >>> "Lift" group. > >>> To post to this group, send email to lift...@googlegroups.com. > >>> To unsubscribe from this group, send email to > >>> liftweb+unsubscr...@googlegroups.com. > >>> For more options, visit this group > >>> athttp://groups.google.com/group/liftweb?hl=en. > > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "Lift" group. > >> To post to this group, send email to lift...@googlegroups.com. > >> To unsubscribe from this group, send email to > >> liftweb+unsubscr...@googlegroups.com. > >> For more options, visit this group > >> athttp://groups.google.com/group/liftweb?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Lift" group. > > To post to this group, send email to lift...@googlegroups.com. > > To unsubscribe from this group, send email to > > liftweb+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/liftweb?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.