Skip to content
Related Articles

Related Articles

Node.js v8.deserialize() Method
  • Last Updated : 28 Jul, 2020

The v8.deserialize() method is an inbuilt application programming interface of the v8 module which is used to deserialize a buffered data into JS value using default deserializer.

Syntax:

v8.deserialize( buffer );

Parameters: This method accepts one parameter as mentioned above and described below:

  • buffer: This is a required parameter, a Buffer / TypedArray / DataView, refers to a buffered data to be deserialized.

Return Value: This method returns JS value after deserializing the buffered data.

Below examples illustrate the use of v8.deserialize() method in Node.js.



Example 1: Filename: index.js




// Accessing v8 module
const v8 = require('v8');
  
// Calling v8.deserialize() 
console.log(v8.deserialize(v8.serialize("geeksforgeeks")));

Run index.js file using the following command:

node index.js

Output:

geeksforgeeks

Example 2: Filename: index.js




// Accessing v8 module
const v8 = require('v8');
  
// Calling v8.deserialize() 
deserialized_data = v8.deserialize(v8.serialize("abcdefg"));
console.log("\nDeserialized data is ");
console.log(deserialized_data);
  
deserialized_data = v8.deserialize(v8.serialize(58375693));
console.log("\nDeserialized data is ");
console.log(deserialized_data);
  
deserialized_data = v8.deserialize(v8.serialize(73847.0234));
console.log("\nDeserialized data is ");
console.log(deserialized_data);
  
deserialized_data = v8.deserialize(v8.serialize('Geek'));
console.log("\nDeserialized data is ");
console.log(deserialized_data);

Run index.js file using the following command:

node index.js

Output:

Deserialized data is
abcdefg

Deserialized data is
58375693

Deserialized data is
73847.0234

Deserialized data is
Geek

Reference: https://nodejs.org/api/v8.html#v8_v8_deserialize_buffer

My Personal Notes arrow_drop_up
Recommended Articles
Page :