admin管理员组

文章数量:1312811

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 ?

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 ?

Share Improve this question edited Nov 4, 2016 at 15:40 TimoStaudinger 42.5k16 gold badges89 silver badges96 bronze badges asked Nov 4, 2016 at 15:37 VLeonovsVLeonovs 2,2515 gold badges26 silver badges46 bronze badges 7
  • 2 Just curious: console.log(myString.length) shows what? – Washington Guedes Commented Nov 4, 2016 at 15:39
  • If it's just to copy, create a div and do innerHTML = myString. – AMagyar Commented Nov 4, 2016 at 15:40
  • Why do you want to copy/log the string? – Felix Kling Commented Nov 4, 2016 at 15:42
  • @FelixKling Why does it matter why he wants to copy the string? – user47589 Commented Nov 4, 2016 at 15:42
  • 2 copy(JSON.stringify(...)) stores the result of JSON.stringify() in the clipboard – Andreas Commented Nov 4, 2016 at 15:52
 |  Show 2 more ments

2 Answers 2

Reset to default 11

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)

You could log it to localStorage:

 localStorage.setItem('JSON String', JSON.stringify(yourObject));

本文标签: javascriptString is not displayed by the Web Console because of sizeStack Overflow