Skip to main content

UNKNOWN

Project description

JSON plus types
***************

Uses builtin json. but adds a lookup dictionary with functions that encode/decode specific types.

default _TYPE_FUNCS dict holds:

_TYPE_FUNCS{
datetime.datetime: encode_datetime,
"DATETIME": decode_datetime,
float:encode_float
}

where encode ande decode datetime functions:

def encode_datetime(date_object):
timestamp = int(1000 * time.mktime(date_object.utctimetuple()))
return {
_TYPE_TAG:"DATETIME",
_VALUE_TAG:timestamp
}

def decode_datetime(timestamp):
return datetime.datetime.utcfromtimestamp(timestamp/1000)

the github repo:
http://github.com/sloev/jsonplustypes
holds a reference javascript implementation of the same json serialization/deserialization

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonplustypes-0.3.tar.gz (1.5 kB view details)

Uploaded Source

File details

Details for the file jsonplustypes-0.3.tar.gz.

File metadata

  • Download URL: jsonplustypes-0.3.tar.gz
  • Upload date:
  • Size: 1.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jsonplustypes-0.3.tar.gz
Algorithm Hash digest
SHA256 cbaa73d9a408013d75e08e201db4124efcd32fa8a557f308cd0585367aecb164
MD5 93cf136ec5dbe9c148ac4c2dbc2ce83a
BLAKE2b-256 550fec997beb46526a91f4be6868f8a9b6fa338b72d80e3954c75853120ca0c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page