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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:09:47+00:00 2026-06-16T20:09:47+00:00

I want to save a json string in MySQL table. The json string comes

  • 0

I want to save a json string in MySQL table. The json string comes from a canvas (using fabricjs).

var jsonCanvas = JSON.stringify(canvas.toDatalessObject());

My first question is, what is the best datatype for saving the json string in MySQL? The Canvas will contain images as well as text and other objects.
Do you think MEDIUMTEXT is enough?

The other question.
Is it possible to save the json string with this prepared statement. I’m doubtful to use the keyword “s” for string.

try {
  $sql = "insert into layout (lt_author, lt_date, lt_category, lt_json_string)
   values (?,?,?,?)";
  $stmt = $mysqli->prepare($sql);
  $stmt->bind_param("ssss",$lt_author, $lt_date, $lt_category, $lt_json_string);
  $stmt->execute();
  $stmt->close();

Thank you for helping 🙂
Greetings Max

  • 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-16T20:09:48+00:00Added an answer on June 16, 2026 at 8:09 pm

    I’m assuming that your SQL is correct.
    I always chose TEXT to store my json string representation of my canvas.
    But there is somethings to consider before you chose how to save your JSON representation.
    See this discussion here: Loading JSON in canvas with fabric.js
    It’s explained the main points that you need observe.

  2. Use .toDatalessObject() instead .toJson() method:
  3. – Pros: As kangax explained in the discussion, toDatalessObject will save just the url source of your svg, so, less data to be saved in your database. By this way, you can maybe use other type to store your json canvas representation (maybe you can use a TINYTEXT type)
    – Cons: You need have the files in your server, because you will reference it when load the canvas again.

  4. How much object will have in your canvas? And what type is this objects? Is more svg or image and text?
  5. You need know because, if you use .toDatalessJson() method and you will have more svg loaded in your canvas, this svg will be converted in Path and PathGroup object, and will be save in your database.
    So, if you have many, many svg in your canvas, maybe the final json string can overflow the size allowed for types TEXT in database (if this happen, there some solutions, like split your json string representation and save in two or more entries in your database).
    But, if this happen frequently, maybe will better chose other type, like MEDIUMTEXT, as you suggest.

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

Sidebar

Related Questions

i just want to ask, how can i save my json file from url
I download json data from server and I want to save them to a
I want to store a playlist of tracks from SoundCloud in a mySQL table.
I parsed data from json to corresponding class data and them want to save
I'm getting an array of strings from a JSON object. I want to save
I want to save Image in Database with JSON web service .without image data
I want to save and load my xml data using XmlReader. But I don't
I'm trying to create two method to serialize/deserialize classes using Json.Net and save/load them
I need to store localisated data from the web, which comes in a JSON
I'm trying to convert results from a query into json. string esql = select

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.