Skip to content

Commit

Permalink
Prep for 2.1.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
ptmcg committed Jan 23, 2023
1 parent 372455d commit 00c948f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Change History
==============

Version 2.1.2 (in development)
------------------------------
Version 2.1.2
-------------
- Added `json_encoder` argument to `Table.json_export`, so that custom data
fields can get exported without raising JSONEncodeError. peps.py example
has been modified to demonstrate this. The `json_encoder` argument can
Expand Down
18 changes: 8 additions & 10 deletions examples/peps.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@
bdfl_peps.sort("id")
bdfl_peps.select("id title year").present()

# (json_encoder arg requires littletable > 2.1.1)
if lt.__version_info__[:3] > (2, 1, 1):
# define a custom JSON encoder for datetime.date field
class JsonDateEncoder(json.JSONEncoder):
def default(self, o):
import datetime
if isinstance(o, datetime.date):
return str(o)
return super().default(o)

class JsonDateEncoder(json.JSONEncoder):
def default(self, o):
import datetime
if isinstance(o, datetime.date):
return str(o)
return super().default(o)


print(bdfl_peps.select("id title created").json_export(json_encoder=(JsonDateEncoder,)))
print(bdfl_peps.select("id title created").json_export(json_encoder=(JsonDateEncoder,)))
2 changes: 1 addition & 1 deletion littletable.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
__version_info__.release_level == "final"
]
)
__version_time__ = "30 Nov 2022 14:53 UTC"
__version_time__ = "23 Jan 2023 21:52 UTC"
__author__ = "Paul McGuire <ptmcg@austin.rr.com>"

NL = os.linesep
Expand Down

0 comments on commit 00c948f

Please sign in to comment.