Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8171539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:29:36+00:00 2026-06-06T21:29:36+00:00

I see how I can write objects to files as described here: How can

  • 0

I see how I can write objects to files as described here: How can I save objects to files in Node.js? but is there a way to take an object and write it in a way that allows me to reload the object into memory including its methods?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:29:37+00:00Added an answer on June 6, 2026 at 9:29 pm

    As @AnthonySottile said before, this can be extremely dangerous and I’m not sure there is ever a good use case for it, but just for kicks and giggles you would need to write your own recursive serializer. Something like this:

    var toString = Object.prototype.toString;
    
    function dump_object(obj) {
        var buff, prop;
        buff = [];
        for (prop in obj) {
            buff.push(dump_to_string(prop) + ': ' + dump_to_string(obj[prop]))
        }
        return '{' + buff.join(', ') + '}';
    }
    
    function dump_array(arr) {
        var buff, i, len;
        buff = [];
        for (i=0, len=arr.length; i<len; i++) {
            buff.push(dump_to_string(arr[i]));
        }
        return '[' + buff.join(', ') + ']';
    }
    
    function dump_to_string(obj) {
        if (toString.call(obj) == '[object Function]') {
            return obj.toString();
        } else if (toString.call(obj) == '[object Array]') {
            return dump_array(obj);
        } else if (toString.call(obj) == '[object String]') {
            return '"' + obj.replace('"', '\\"') + '"';
        } else if (obj === Object(obj)) {
            return dump_object(obj);
        }
        return obj.toString();
    }
    

    This will handle most types, but there is always the chance of an oddball messing it up so I would not use this in production. Afterwards unserializing is as easy as:

    eval('var test = ' + dump_to_string(obj))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can see that GD library is for images. But I can't see differences
I can see that Collections.unmodifiableSet returns an unmodifiable view of the given set but
I'm trying to write a general function that i can pass an object to
I can see some potential difficulties with this concept but the idea is: I
I can see there are a lot of questions for getting the number of
I can see that the PopUp dropdown of a combobox gets closed if we
I wrote a little utility class that saves BitmapSource objects to image files. The
I've written a little Python (2.7.2+) module (called TWProcessing ) that can be described
I can see the Graphical Layout of the XML file within the /res/layout folder,
I can see it looks like an alias for an unsigned int pointer, right?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.