Skip to content

Commit

Permalink
Cleanup generator, expose a to_json_dict.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfine committed Apr 15, 2015
1 parent 9511935 commit a3e397c
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions generator/sbpg/targets/resources/sbp_construct_template.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,6 @@ class ((( m.identifier | classnameify )))(SBP):
self.payload = ((( m.identifier | classnameify )))._parser.build(c)
return self.pack()

def to_json(self):
"""Produce a JSON-encoded SBP message.
"""
d = super( ((( m.identifier | classnameify ))), self).to_json_dict()
j = walk_json_dict(exclude_fields(self))
d.update(j)
return json.dumps(d)

@staticmethod
def from_json(s):
"""Given a JSON-encoded string s, build a message object.
Expand All @@ -163,6 +154,12 @@ class ((( m.identifier | classnameify )))(SBP):
d = json.loads(data)
sbp = SBP.from_json_dict(d)
return ((( m.identifier | classnameify )))(sbp)

def to_json_dict(self):
d = super( ((( m.identifier | classnameify ))), self).to_json_dict()
j = walk_json_dict(exclude_fields(self))
d.update(j)
return d
((*- endif *))
((* endif *))
((*- else *))
Expand Down

0 comments on commit a3e397c

Please sign in to comment.