From c875f46fe83381d5917b3a7a8453e2ae58d233a8 Mon Sep 17 00:00:00 2001
From: Lukas Larsson Returns an Erlang term that is the result of decoding
binary object
+> Bin = term_to_binary(hello). +<<131,100,0,5,104,101,108,108,111>> +> hello = binary_to_term(Bin). +hello +
When decoding binaries from untrusted sources,
consider using
Failure:
+> binary_to_term(<<131,100,0,5,104,101,108,108,111>>, [safe]). +** exception error: bad argument +> hello. +hello +> binary_to_term(<<131,100,0,5,104,101,108,108,111>>, [safe]). +hello +
See also
Returns a binary data object that is the result of encoding
-
This can be used for various purposes, for example, writing a term to a file in an efficient way, or sending an Erlang term to some type of communications channel not supported by distributed Erlang.
++> Bin = term_to_binary(hello). +<<131,100,0,5,104,101,108,108,111>> +> hello = binary_to_term(Bin). +hello +
See also