Skip to content

Commit 739ca91

Browse files
committed
allow encoding immutable objects such as tuple
1 parent eb2d618 commit 739ca91

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- Copyright: (C) Qianqian Fang (2019-2022) <q.fang at neu.edu>
66
- License: Apache License, Version 2.0
7-
- Version: 0.5.2
7+
- Version: 0.5.3
88
- URL: https://github.com/NeuroJSON/pyjdata
99

1010
[![Build Status](https://travis-ci.com/fangq/pyjdata.svg?branch=master)](https://travis-ci.com/fangq/pyjdata)

jdata/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from .jfile import load, save, show, loadt, savet, loadb, saveb, jext
3737
from .jdata import encode, decode, jdtype, jsonfilter
3838

39-
__version__ = "0.5.2"
39+
__version__ = "0.5.3"
4040
__all__ = [
4141
"load",
4242
"save",

jdata/jdata.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ def encode(d, opt={}):
115115
elif np.isinf(d):
116116
return "_Inf_" if (d > 0) else "-_Inf_"
117117
return d
118-
elif isinstance(d, list) or isinstance(d, tuple) or isinstance(d, set) or isinstance(d, frozenset):
118+
elif isinstance(d, list) or isinstance(d, set):
119119
return encodelist(d, opt)
120+
elif isinstance(d, tuple) or isinstance(d, frozenset):
121+
return encodelist(list(d), opt)
120122
elif isinstance(d, dict):
121123
return encodedict(d, opt)
122124
elif isinstance(d, complex):
@@ -221,8 +223,10 @@ def decode(d, opt={}):
221223
elif d == "-_Inf_":
222224
return float("-inf")
223225
return d
224-
elif isinstance(d, list) or isinstance(d, tuple) or isinstance(d, set) or isinstance(d, frozenset):
226+
elif isinstance(d, list) or isinstance(d, set):
225227
return decodelist(d, opt)
228+
elif isinstance(d, tuple) or isinstance(d, frozenset):
229+
return decodelist(list(d), opt)
226230
elif isinstance(d, dict):
227231
if "_ArrayType_" in d:
228232
if isinstance(d["_ArraySize_"], str):

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
setup(
77
name = 'jdata',
88
packages = ['jdata'],
9-
version = '0.5.2',
9+
version = '0.5.3',
1010
license='Apache license 2.0',
1111
description = 'Encoding and decoding Python data structrues using portable JData-annotated formats',
1212
long_description=readme,
@@ -15,7 +15,7 @@
1515
author_email = 'fangqq@gmail.com',
1616
maintainer= 'Qianqian Fang',
1717
url = 'https://github.com/NeuroJSON/pyjdata',
18-
download_url = 'https://github.com/NeuroJSON/pyjdata/archive/v0.5.2.tar.gz',
18+
download_url = 'https://github.com/NeuroJSON/pyjdata/archive/v0.5.3.tar.gz',
1919
keywords = ['JSON', 'JData', 'UBJSON', 'BJData', 'OpenJData', 'NeuroJSON', 'JNIfTI', 'JMesh', 'Encoder', 'Decoder'],
2020
platforms="any",
2121
install_requires=[

0 commit comments

Comments
 (0)