Jump to content

Recommended Posts

hey guys i have a data attribute with a json string of about 291478 characters long so far and counting...but im thinking the data attribute has a max length (although im unable to find any details on this so far) as my json string gets cut off 3/4's of the way through

 

when i echo string outside data attribute it shows perfectly fine...does anyone know the max length?

 

also i need to find somewhere else to store this json string...the data attribute had been perfect up until now! :(

Link to comment
https://forums.phpfreaks.com/topic/298145-data-attribute/
Share on other sites

Data attributes are unlimited but do have limits due to system memory. You should consider these more like meta fields and output data normally.

Strings have a limit of 2GB but the overall script execution also has a limit determined by your php.ini memory settings and also server resources.

 

If you are having memory issues you may want to rethink how are fetching and displaying the data.

 

json_decode() the json file and store data into a database

 

Can read from saved json files directly like a cache but have to load the entire file each time and parse it.

Link to comment
https://forums.phpfreaks.com/topic/298145-data-attribute/#findComment-1520747
Share on other sites

well the data originally comes from the database then i use

	public function encode($data = array())
	{
	    $utf8 = new UTF8();
	    $data = $utf8->encode($data);
	    
		$json = json_encode($data);
        $json = htmlentities(stripslashes($json), ENT_QUOTES);

        return $json;
	}

to encode to json so i can use the data via js....and i call the data like so:

sub_category.data('sub-categories');

the after encoded the json looks like a perfect json string....but when added to the data attribute it only has about 3/4 of the data and not formed correctly

Link to comment
https://forums.phpfreaks.com/topic/298145-data-attribute/#findComment-1520756
Share on other sites

Really...2500 rows then cut, all this data needs to be displayed all one time?

It's hard for me to envision why you need to do this.

 

Possibly unescaped encoding issue

 

Have any examples of the data where it gets cut off?

Edited by QuickOldCar
Link to comment
https://forums.phpfreaks.com/topic/298145-data-attribute/#findComment-1520758
Share on other sites

ok well this is embarrassing my json isn't valid

 

basically i have 3 columns like so:

"name":"10"      Singles"

10" Singles   -    but because of the quote make which represents inch, json fails.

 

strip slashes worked like a charm....thank you

Edited by Destramic
Link to comment
https://forums.phpfreaks.com/topic/298145-data-attribute/#findComment-1520761
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.