Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String is not displayed by the Web Console because of size

I'm using JSON.stringify(myString) in Mozilla Firefox to convert a JavaScript object to a JSON string.

This function is working very well, but myString is very large, and I have got an exception in Developer's Console:

The string you are trying to view is too long to be displayed by the Web Console.

And I can't fully copy json string.

I was trying to output this string in alert, but it has limit too. If there is any work-around how to solve it ?

like image 823
VLeonovs Avatar asked Dec 08 '22 20:12

VLeonovs


2 Answers

Firefox und Chrome provide some helpers available in the console.
One of these helpers is copy()

Firefox: copy(object)
New in Firefox 38. Copy the argument to the clipboard. If the argument is a string, it's copied as-is. If the argument is a DOM node, its outerHTML is copied. Otherwise, JSON.stringify will be called on the argument, and the result will be copied to the clipboard.

Chrome: copy(object)
copies a string representation of the specified object to the clipboard.

For Firefox it would be:

copy(yourObject)
like image 196
Andreas Avatar answered Dec 11 '22 09:12

Andreas


You could log it to localStorage:

 localStorage.setItem('JSON String', JSON.stringify(yourObject));
like image 24
Scott Marcus Avatar answered Dec 11 '22 11:12

Scott Marcus