Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.python > #5356

Re: [Python-de] Binärdaten in JSON

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Hardy Erlinger <hardy.erlinger@posteo.de>
Newsgroups de.comp.lang.python
Subject Re: [Python-de] Binärdaten in JSON
Date Fri, 30 Nov 2018 11:40:25 +0100
Lines 39
Message-ID <mailman.22.1543574810.25456.python-de@python.org> (permalink)
References <16bf5ba5-26db-dddf-0a42-ddc61670a4ae@thomas-guettler.de> <mailman.4.1543506244.25456.python-de@python.org> <hmj5df-kdq.ln1@gate.homenet> <0e512eb9-3a48-7f63-b2d5-6f6acfa48da3@thomas-guettler.de> <2141174c-1718-f16e-f056-15af93d0b918@sschwarzer.net> <3169df7e-4289-420e-f5aa-ed4a8b7acf7a@posteo.de>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de fNTvkWSTyWFdhD7lvIn/nwIgm7C9jxL8c0L/qwuAMhBQ==
Return-Path <hardy.erlinger@posteo.de>
X-Original-To python-de@python.org
Delivered-To python-de@mail.python.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1543574427; bh=QRojIv00Sa0vKAeZdI9F3tPM0mJsjfPehU9WPNIQrBM=; h=Subject:To:From:Date:From; b=Ix/hN+rzBUbxZSQIDpM/FavuGRGaPd6bSoFEXMUAysoks6dxebyZiANHvjNnWV5SB yEehp9wcbqNlLeGhJ5dNGd+VYIHzQ6VLe77r3m/v2nSd2sIjI9XQuLgK8QhvkKgrzJ YSLSy1gXwJQqJuLCm2B8qwagZkzUxDJSLR6c7mGU3V8kfIbdJB+Er0iwMhLwY4clcp SmlJv9AZfRguuk67+L+oy05Ek1yU/+m8VQW9rmA2S0omwPdVt9MI3Qh492h/27z9UQ 9jMn1i8FYRIVmEzzRMBTyEcF5RpaKvyZvaO+DZM0r68rIZqoV+22RO/xYhEKgSTjGJ s9yBvzmnVxpVg==
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
In-Reply-To <2141174c-1718-f16e-f056-15af93d0b918@sschwarzer.net>
Content-Language de-DE
X-BeenThere python-de@python.org
X-Mailman-Version 2.1.29
Precedence list
List-Id Die Deutsche Python Mailingliste <python-de.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-de/>
List-Post <mailto:python-de@python.org>
List-Help <mailto:python-de-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <3169df7e-4289-420e-f5aa-ed4a8b7acf7a@posteo.de>
X-Mailman-Original-References <16bf5ba5-26db-dddf-0a42-ddc61670a4ae@thomas-guettler.de> <mailman.4.1543506244.25456.python-de@python.org> <hmj5df-kdq.ln1@gate.homenet> <0e512eb9-3a48-7f63-b2d5-6f6acfa48da3@thomas-guettler.de> <2141174c-1718-f16e-f056-15af93d0b918@sschwarzer.net>
Xref csiph.com de.comp.lang.python:5356

Show key headers only | View raw


On 30.11.2018 11:27, Stefan Schwarzer wrote:
> Hallo Thomas,
>
> On 30/11/2018 09:48, Thomas Güttler wrote:
>> Am 29.11.18 um 18:19 schrieb Thomas Orgelmacher:
>>> Am 29.11.18 um 16:36 schrieb Thomas Güttler:
>>>> Hat jemand schon mal mit binären Daten in JSON gearbeitet?
>>>>
>>>> Welche Lösungsvariante habt ihr gewählt?
>>>>
>>>> V1: http://bsonspec.org/
>>>> V2: http://bjson.org/
>>>> V3: https://github.com/FasterXML/smile-format-specification
>>>> V4: ....
>>> base64?
>> Also wie ist das mit base64 gemeint? Wie ist das JSON ähnliches Datenformat,
>> welches auch binäre Daten übertragen kann?
>>
>> Ich suche eine Lösung. Ein Datenformat. Ich suche nicht ein gebasteltes Work-around.
> Zu "Ich suche eine Lösung": Wir wissen ja gar nicht,
> was dein konkretes Problem ist, außer "mit binären
> Daten in JSON arbeiten."
>
Exakt. Base64 ist kein Workaround. Damit kannst Du ganz ohne externe 
Libraries binäre Daten in JSON-Feldern serialisieren. Beispiel:

person = {
     'name': 'Luke Skywalker',
}
pic_content = pathlib.Path(pic_path).read_bytes()
person['picture'] = base64.encodebytes(pic_content).decode('ascii')

Das dict kann nun problemlos mit json.dumps() serialisiert werden. Das 
'picture'-Attribut ist reines ASCII. Es muss kein neues Binärformat 
eingeführt werden, beim Tracen der Messages zwischen Client und Server 
ist alles weiterhin JSON und damit sehr gut lesbar etc. etc.

Viele Grüße,
Hardy

Back to de.comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

[Python-de] Binärdaten in JSON Thomas Güttler <guettliml@thomas-guettler.de> - 2018-11-29 16:36 +0100
  Re: [Python-de] Binärdaten in JSON Thomas Orgelmacher <trash@odbs.org> - 2018-11-29 18:19 +0100
    Re: [Python-de] Binärdaten in JSON Arnold Krille <arnold@arnoldarts.de> - 2018-11-29 19:46 +0100
    Re: [Python-de] Binärdaten in JSON Thomas Güttler <guettliml@thomas-guettler.de> - 2018-11-30 09:48 +0100
      Re: [Python-de] Binärdaten in JSON Thomas Orgelmacher <trash@odbs.org> - 2018-11-30 19:24 +0100
      Re: [Python-de] Binärdaten in JSON Thomas Orgelmacher <trash@odbs.org> - 2018-11-30 19:37 +0100
    Re: [Python-de] Binärdaten in JSON Stefan Schwarzer <sschwarzer@sschwarzer.net> - 2018-11-30 11:27 +0100
    Re: [Python-de] Binärdaten in JSON Hardy Erlinger <hardy.erlinger@posteo.de> - 2018-11-30 11:40 +0100
    Re: [Python-de] Binärdaten in JSON Thomas Güttler <guettliml@thomas-guettler.de> - 2018-11-30 15:01 +0100
    Re: [Python-de] Binärdaten in JSON Thomas Jollans <tjol@tjol.eu> - 2018-12-03 10:21 +0100
    Re: [Python-de] Binärdaten in JSON Thomas Güttler <guettliml@thomas-guettler.de> - 2018-12-04 10:25 +0100
      Re: [Python-de] Binärdaten in JSON Thomas Güttler <guettliml@thomas-guettler.de> - 2018-12-13 12:14 +0100
        [Python-de] IFF Format: Dict? Thomas Güttler <guettliml@thomas-guettler.de> - 2018-12-14 09:04 +0100
          Re: [Python-de] IFF Format: Dict? Thomas Güttler <guettliml@thomas-guettler.de> - 2019-01-04 14:31 +0100
            Re: [Python-de] IFF Format: Dict? Thomas Orgelmacher <trash@odbs.org> - 2019-01-05 20:58 +0100
        Re: [Python-de] IFF Format: Dict? Armin Stross-Radschinski <developer@acsr.de> - 2018-12-14 10:31 +0100
        [Python-de] IFF Format Verwendung Christopher Arndt <chris@chrisarndt.de> - 2018-12-14 14:53 +0100
    Re: [Python-de] Binärdaten in JSON Stefan Behnel <python-de@behnel.de> - 2018-12-06 09:51 +0100

csiph-web