View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
James Raspass > JavaBin > JavaBin



Annotate this POD


View/Report Bugs
Module Version: 0.9   Source  


JavaBin - Apache Solr JavaBin (de)serializer


 use JavaBin;

 my $javabin = to_javabin { foo => 'bar' };

 my $href = from_javabin $javabin;


JavaBin is a compact binary format used by Apache Solr.

For more information on this format see the Solr Wiki.

This package provides a serializer and deserializer for this format.

WARNING: The API of this module is unstable and may change without warning (any change will be appropriately documented in the changelog).



 my $result = from_javabin $javabin;

Accepts one argument, a binary string containing the JavaBin.

Returns a scalar representation of the data, be that undef, number, string, or reference.

This function does no error checking, hand it invalid JavaBin and it will probably die.


 my $javabin = to_javabin $data;

Accepts one argument, a Perl scalar, be that undef, number, string, or reference.

Returns a Perl string containing the binary JavaBin.

This function does no error checking, hand it invalid JavaBin and it will probably die.


This section describes how JavaBin maps Perl values to JavaBin values and vice versa. These mappings are designed to "do the right thing" in most circumstances automatically, preserving round-tripping characteristics (what you put in comes out as something equivalent).

Runtime errors are avoided with a preference to encoding more exoctic Perl values (think regular expressions, tied values, etc.) to a JavaBin null.

JavaBin -> Perl


A JavaBin null becomes undef in Perl.

true, false

JavaBin booleans become JavaBin::Bool objects in Perl which overload to behave like literal 1 and 0 respectively.

byte, short, int, long

JavaBin integers are returned as scalars (with IV set), with the requirement of a 64bit Perl for longs.

float, double

JavaBin floating point values are returned as scalars (with NV set).


JavaBin Strings are returned as Perl strings with the UTF-8 flag on.


A JavaBin Date is returned as a string in ISO 8601 format. This will likely change to be a JavaBin::Date object in future to facilitate round-tripping.


A JavaBin enum is returned as a JavaBin::Enum object.


A JavaBin array is returned as a Perl array.


A JavaBin Iterator is flattened into a Perl array. This will likely change to be a JavaBin::Iterator object in future to facilitate round-tripping.

Map, NamedList, SimpleOrderedMap

A JavaBin Map, NamedList, or SimpleOrderedMap is returned as a Perl hash. This is technically wrong all three allow repeating keys but Perl does not, and SimpleOrderedMap, as the name implies, has an order but Perl does not.

This will need to change in the future.

Perl -> JavaBin



This package was inspired by the Ruby JavaBin library. Both that library and the Java JavaBin library proved very helpful in understanding JavaBin.


Copyright © 2013–2014 by James Raspass

This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: