<div dir="ltr"><div>This is a general problem in trying to use JSON to send arbitrary python objects. Its not made for that purpose, JSON itself only supports a very limited grammar (only one sequence type for instance, as you noticed), so in general you will need to specify your own encoding/decoding for more complex objects you want to send over JSON.</div><div><br></div><div>In the case of an object dtype, dtypestr = str(dtype) gives you a nice JSONable string representation, which you can convert back into a dtype using np.dtype(eval(dtypestr))</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Dec 13, 2014 at 9:25 AM, Sebastian <span dir="ltr"><<a href="mailto:sebix@sebix.at" target="_blank">sebix@sebix.at</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'll just comment on the creation of your dtype:<br>
<span><br>
> dt = [("<f8", "<f8")]<br>
<br>
</span>You are creating a dtype with one field called '<f8' and with type '<f8':<br>
<span><br>
>>> dt = [("<f8", "<f8")]<br>
</span>>>> dty = np.dtype(dt)<br>
>>> dty.names<br>
<br>
('<f8',)<br>
<br>
What you may want are two fields with type '<f8' and without fieldname:<br>
<span><br>
>>> dt = [("<f8", "<f8")]<br>
</span>>>> dty = np.dtype(('<f8,<f8'))<br>
>>> dty.names<br>
<br>
('f0', 'f1')<br>
>>> dty.descr<br>
<br>
[('f0', '<f8'), ('f1', '<f8')]<br>
<br>
I can't help you with the json-module and what it's doing there. As the<br>
output is unequal to the input, I suspect JSON to be misbehaving here.<br>
If you need to store the dtype as strings, not as binary pickle, you can<br>
use pickle.dumps and pickle.loads<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div></div>