Ticket #29 (new defect)

Opened 5 years ago

Move JSON serialization to model

Reported by: wyatt Owned by: wyatt
Priority: minor Milestone: 0.5
Component: Model Version: 0.3
Keywords: Restler, JSON, __simplify__ Cc:

Description

Move JSONification to model:

  • Rename __simplify__ method to to_builtin
  • Add to_json method to model classes (typically just simplejson.dumps(self.to_builtin())
  • Add to_json_collection staticmethod to model classes (typically just simplejson.dumps([member.to_builtin() for member in collection])
  • Make restler.RestController._get_json_content just call to_json or to_json_collection on model classes (intead of JSONifying the result of __simplify__)
  • Leave services._get_json_content pretty much as is, but don't wrap a single result in a list (check for typeof Array in JS code; maybe add num_results to result object
Note: See TracTickets for help on using tickets.