Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ionic JSON.stringify fails on array

ANSWERED

 

On the Ionic I am finding the JSON.stringify fails if the outermost object is an array.  I can itterate through the collection and print each one to console, and in the companion I can call JSON.stringify, but it fails on the Ionic.  Is there any way around this other than itterating?  I'm developing and it is nice to be able to stringify the raw data.  The json looks like below, just more elements but still well below the 1027 byte limit.

 

[{"DisplayText":"Server 1","Status":"Online"}, {"DisplayText":"Server 2","Status":"Offline"}]

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

I'm not sure exactly what the device limit is, but it's definitely shorter than the companion.

 

You could experiment with different lengths to see which works,

View best answer in original post

Best Answer
4 REPLIES 4

The error when calling console.log(JSON.stringify on the object is:

** ERROR: Could not convert log string **

 

Best Answer

@SkipFire wrote:

The error when calling console.log(JSON.stringify on the object is:

** ERROR: Could not convert log string **

 


Essentially the string is too long to output to the console. This is fixed in the next version, it will truncate automatically.



Best Answer

@JonFitbit, so is the limit shorter for the Ionic than for the companion?  The same string can be stringified on the companion with no problem.  What is the limit for the console.log on the Ionic?

Best Answer

I'm not sure exactly what the device limit is, but it's definitely shorter than the companion.

 

You could experiment with different lengths to see which works,

Best Answer