({{, (RefLink[BinaryDeserialize, paclet:ref/BinaryDeserialize])[(RefLink[ByteArray, paclet:ref/ByteArray])[…]] 
recovers an expression from a binary representation generated by (RefLink[BinarySerialize, paclet:ref/BinarySerialize]).}, {, (RefLink[BinaryDeserialize, paclet:ref/BinaryDeserialize])[(RefLink[ByteArray, paclet:ref/ByteArray])[…],h]
wraps h around the expression produced before returning it.}})

OpenersNotesSection(Spacer1)Details

(RefLink[BinaryDeserialize, paclet:ref/BinaryDeserialize])[(RefLink[ByteArray, paclet:ref/ByteArray])[…]] gives (RefLink[$Failed, paclet:ref/$Failed]) if the byte array was not one that could have been generated from an expression by (RefLink[BinarySerialize, paclet:ref/BinarySerialize]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (6)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Serialize an expression:

bin=BinarySerialize[{1,2,3}]

Deserialize it:

BinaryDeserialize[bin]

Serialize a graphic:

BinarySerialize[Plot[Sin[x], {x,0,Pi}]]

Convert the byte array back to an expression:

BinaryDeserialize[%]

OpenersExampleSection1(Spacer1)Scope  (3)

Serialize a general expression:

bin=BinarySerialize[Solve[α x+β y==γ &&β x-y==η,{x,y}]]

Deserialize it:

BinaryDeserialize[bin]

Serialize an unevaluated expression:

bin=BinarySerialize[Unevaluated[1+1]]

Deserialize it and keep it held:

BinaryDeserialize[bin, Hold]

Receive a serialized expression from an unknown source:

data = ByteArray["NzpmAXMOQmlnQmFkRnVuY3Rpb25TCmVyYXNlIGRpc2s="]

Wrap the result in (RefLink[HoldComplete, paclet:ref/HoldComplete]) to prevent unexpected evaluation:

BinaryDeserialize[data,HoldComplete]

OpenersExampleSection3(Spacer1)Properties & Relations  (1)

Serialized data from files should be read in using binary-mode functions such as (RefLink[BinaryReadList, paclet:ref/BinaryReadList]):

data=ByteArray[BinaryReadList["ExampleData/atoms.wxf"]]

BinaryDeserialize[%]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[BinarySerialize, paclet:ref/BinarySerialize])  ▪  (RefLink[ImportByteArray, paclet:ref/ImportByteArray])  ▪  (RefLink[Import, paclet:ref/Import])  ▪  (RefLink[ToExpression, paclet:ref/ToExpression])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Wolfram Language Expressions in Files, paclet:guide/WolframLanguageExpressionsInFiles])}, {▪(RefLinkPlain[Importing and Exporting, paclet:guide/ImportingAndExporting])}, {▪(RefLinkPlain[Importing & Exporting Database Formats, paclet:guide/ImportingAndExportingDatabaseFormats])}, {▪(RefLinkPlain[Binary Data, paclet:guide/BinaryData])}, {▪(RefLinkPlain[Memory Measurement & Optimization, paclet:guide/MemoryMeasurementAndOptimization])}, {▪(RefLinkPlain[Wolfram Language File Formats, paclet:guide/WolframLanguageFileFormats])}})}})