help on pickle tool

V

virg

Yes your are right. I will send a dictionary object from the server to
the client.
I already have client which is written in python. But we are migrating
the python client which is a command line tool to Web UI client
(java). If it is possible to call python function from java, i need to
read more about jython, i am new to this.
 
H

hanumizzle

Yes your are right. I will send a dictionary object from the server to
the client.
I already have client which is written in python. But we are migrating
the python client which is a command line tool to Web UI client
(java).

Please explain 'Web UI'. Can Python perform an equivalent function?

-- Theerasak
 
V

virg

Hi,

Yes, using python client we are able deserialize data using

r = pickle.loads(result).

where result is a response from the server and r is a dictionary after
deserialization.
For serialisation at the server written in python using
pickle.dumps(result, 2)

Now we are developing web based Client using java. So we are writing
client in java. If server and client are in python we dont see any
problems since we are using same serialisation tool "pickle". Now we
have seen problems because we are writing client in java. we did not
find equivalent function on java for this tool pickle. If i use
standard java desrialisation functions i am getting error as invalid
header becasue of incompatibility between python and java. Please help
me if you have any clue

regards,
- Virg
 
K

Kirill Simonov

Hi,

I'm somewhat late to this discussion, but as the author of PyYAML, I'd
like to put my 2c in.


Is it possible to deserialize the data by java which serialized by
Python or is there any compatibility issue. Is there any equivalent
pickle tool on java which supports this operation. so that i can use
across languages.

You may serialize/deserialize your data to YAML using PyYAML
(http://pyyaml.org/wiki/PyYAML) on the Python side and jvyaml
(https://jvyaml.dev.java.net/) on the Java side. You may also check
JSON (http://json.org/) as other posters suggested.


I don't think JSON is a subset of YAML.

It is.


JSON is almost identical to Python's expression syntax, of course,
while YAML isn't even close.

A valid Python list/dict expression is likely to be a valid YAML
expression. For instance

{ "odd": [1, 3, 5, 7, 9], "even": [2, 4, 6, 8] }

is both valid Python and valid YAML.


than JavaScript's expression syntax? are you sure you're not
confusing libraries with standards here? (has anyone even managed to
write a YAML library that's small and simple enough to be "obviously
correct"?)

I've written a complete YAML parser and I must admit it hasn't been
extremely difficult. The YAML syntax is very close to Python and I just
needed to rewrite YAML grammar using Python as a model. The PyYAML
parser is LL(1), which is as simple as it could be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,614
Members
45,289
Latest member
stfp04

Latest Threads

Top