Skip to main content

Django JSON encoder with numpy support.

Project description

PyPi MIT TravisCI Coverage Supported Python implementations Supported Python versions

Introduction

Subclass of standard Django JSON encoder [1] that can encode some numpy types (integers, floats and arrays).

Installation

  • Supported Python versions are: 3.6 and 3.7-dev.

  • Supported Django versions are: 2.0

pip install --upgrade django-numpy-json-encoder

Usage

# -*- encoding: utf-8 -*-
# ! python3

import numpy as np
from django.http import JsonResponse
from django.views import View

from django_numpy_json_encoder.numpy_encoder import NumpyJSONEncoder


class ExampleView(View):
    # noinspection PyMethodMayBeStatic
    def post(self, *args, **kwargs):
        numpy_array = np.random.rand(8, 42).astype(np.float32)

        return JsonResponse(data={'array': numpy_array}, encoder=NumpyJSONEncoder, safe=True)

License

The MIT License (MIT)

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

django-numpy-json-encoder-0.1.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_numpy_json_encoder-0.1.3-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file django-numpy-json-encoder-0.1.3.tar.gz.

File metadata

File hashes

Hashes for django-numpy-json-encoder-0.1.3.tar.gz
Algorithm Hash digest
SHA256 bd99d535e6b726240cf2ef6a53c9421f46429b9411cf33ef5e0432783482f1d3
MD5 e43563eee2e7250956447a100a75b716
BLAKE2b-256 50db952fa5eea7f99f61e2bd8fca51e444efd1f759121cc73e350fe45e270d85

See more details on using hashes here.

File details

Details for the file django_numpy_json_encoder-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for django_numpy_json_encoder-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6e7674baf5269a48af61979af4b95c14b1754ad0dbb368d500b45cfe61bde548
MD5 29f0c372452ae3a7555d6e486761f7f1
BLAKE2b-256 7a5457c6aaf9ad4adc4092ff7414343de53fbde78f38e8efc76e1dc33cebab25

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