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 802903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:40:24+00:00 2026-05-14T23:40:24+00:00

I want to convert the html tag objects to json object in the javascript

  • 0

I want to convert the html tag objects to json object in the javascript in order to send them to the server from the javascript. As i have to save these objects at the Ruby on Rails server. These HTML objects is the canvas tag object and the graphics objects created using CAKE API. I have used the stringify function but it is not working.
Here is my code:

window.onload=function()
{
    var CAKECanvas = new Canvas(document.body, 1000,1000);
    var canvas=CAKECanvas.canvas;
    var text=document.createElement('textarea');
    text.id="text";
    text.rows="100";
    text.cols="200";
    document.body.appendChild(text);
    canvas.style.borderStyle="solid";
    canvas.style.borderColor="black";
var rect= new Circle();
    rect.radius=100;
    rect.centered=true;
    rect.cx=Math.random() * 500;
    rect.cy= Math.random() * 300;
    rect.stroke= false;
    rect.fill= "red";
    rect.xDir = Math.random() > 0.5?1:-1;
rect.yDir = Math.random() > 0.5?1:-1;
    var obj=new Object;
    var count = 0,k;
    for (k in rect)
        {
            if (rect.hasOwnProperty(k))
                {
                    count++;
                    obj[k]=rect[k];
                }
        }
    alert(count);
rect.addFrameListener(function(t, dt)
    {
                this.cx += this.xDir * 50 * dt/1000;
        this.cy += this.yDir * 50 * dt/1000;
        if (this.cx > 550)
        {
            this.xDir = -1;
        }
        if (this.cx < 50)
        {
            this.xDir = 1;
        }
        if (this.cy > 350)
        {
            this.yDir = -1;
        }
        if (this.cy < 50)
        {
            this.yDir = 1;
        }
    }
);

CAKECanvas.append(rect);
    var carAsJSON = JSON.stringify(obj); /////////////////NOT CONVERTING THE OBJECT OBJ     INTO JSON OBJECT
}
  • 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-05-14T23:40:25+00:00Added an answer on May 14, 2026 at 11:40 pm

    Only primitive values (strings, dates, booleans, numbers) and objects and array structures are possible to serialize into JSON. This mean that other host-objects like RegExp or Canvas cannot be serialized.

    In short, JSON is limited to data (‘information’).

    So, you will either have to save the created markup using .innerHTML, or save the data so that it can be recreated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some html files that I want to convert to text. I have
I want to convert plaintext to link for an input I have. The HTML
i want to convert from Latitude, Longitude to GPS tag of ExifInterface Ex: 10.34534564
I want to convert HTML to PDF on the server to allow a client
I want to remove all html tag from the text. But I don't want
I have an HTML file and i want to convert to XML document only
I want to convert following html code into continuous string using jquery/javascript. <ul> <li>one</li>
I want to convert all texts in a string into html entities but preserving
I want to convert these URLs to SEO friendly URLs: index.php?t=1&s=1&offset=50&hits=50 ---> index-t-1-s-1-offset-50-hits-50.html index.php?t=1&s=1
I want to use the Discount C-library to convert Markdown text into HTML. I

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.