Skip to main content

Module for serializing and de-serializing Java objects.

Project description

Latest Version License Travis-CI status Coveralls status

python-javaobj is a python library that provides functions for reading and writing (writing is WIP currently) Java objects serialized or will be deserialized by ObjectOutputStream. This form of object representation is a standard data interchange format in Java world.

The javaobj module exposes an API familiar to users of the standard library marshal, pickle and json modules.

About this repository

This project is a fork of python-javaobj by Volodymyr Buell, originally from Google Code and now hosted on GitHub.

This fork intends to work both on Python 2.7 and Python 3.4+.

Compatibility Warning: object transformer

As of version 0.2.0, the notion of object transformer from the original project as been replaced by an object creator.

The object creator is called before the deserialization. This allows to store the reference of the converted object before deserializing it, and avoids a mismatch between the referenced object and the transformed one.

Compatibility Warning: bytes arrays

As of version 0.2.3, bytes arrays are loaded as a bytes object instead of an array of integers.

Features

  • Java object instance unmarshaling

  • Java classes unmarshaling

  • Primitive values unmarshaling

  • Automatic conversion of Java Collections to python ones (HashMap => dict, ArrayList => list, etc.)

  • Basic marshalling of simple Java objects

Requirements

  • Python >= 2.7 or Python >= 3.4

  • Maven 2+ (for building test data of serialized objects. You can skip it if you do not plan to run tests.py)

Usage

Unmarshalling of Java serialised object:

import javaobj

jobj = self.read_file("obj5.ser")
pobj = javaobj.loads(jobj)
print(pobj)

Or, you can use Unmarshaller object directly:

import javaobj

marshaller = javaobj.JavaObjectUnmarshaller(open("objCollections.ser"))
pobj = marshaller.readObject()

self.assertEqual(pobj.value, 17)
self.assertTrue(pobj.next)

pobj = marshaller.readObject()

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

javaobj-py3-0.2.4.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

javaobj_py3-0.2.4-py2.py3-none-any.whl (16.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file javaobj-py3-0.2.4.tar.gz.

File metadata

  • Download URL: javaobj-py3-0.2.4.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for javaobj-py3-0.2.4.tar.gz
Algorithm Hash digest
SHA256 b8b0d310fd97e1c7914d7911ee9d3f4b3d84d2a674aa95a4b0da3d8f155fc1bb
MD5 f669bb8099380e3dd84db3d542aa5b68
BLAKE2b-256 119aa247aefa0383c3fff8c7f96b3b61a82e96c171ef4443e7940bd875a2e362

See more details on using hashes here.

File details

Details for the file javaobj_py3-0.2.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for javaobj_py3-0.2.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 33212878868c163ff5931b509a9fde033e0e931188bab6be70d698c2613e9dc1
MD5 86abf14d06c518cbdba88e6166501fc1
BLAKE2b-256 6a7d1979d67bb8f6c5babb8dda0cb79d6d4663ef9a039c193b5adcc787a86285

See more details on using hashes here.

Supported by

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