JSON Yes it is! ! !

Transfer: https: //blog.csdn.net/HaHa_Sir/article/details/79025127

解决 js报错:Uncaught TypeError- Cannot use 'in' operator to search for 'length' in [{"id":"636","...

Scenes

Reception using $ .getJSON (url, {id, paramter}, function (data) {})

The rear end of the mvc returns JsonResult types of data

When he returned to get the data reported this wrong, but also among themselves for json format data empty, various attempts to solve the problem, leaving no tears technology!

The list is returned when a direct throw jsonresult not have this problem!

 

Later I saw an article about 

1, according to the error code into the source jQuery positioning, $. Each traversal method is json objects , rather than json string. When the incoming json traversal strings when it will error: Can not use 'in' operator to search for ...

2, the solution (the json json string into the object to, the following three methods.)

     

. 1 , the eval = Data ( " ( " + jsonStr + " ) " );    // native js method 
2 , the JSON.parse Data = (jsonStr);   // native js methods 
. 3 , Data = $ .parseJSON (jsonStr); // need jquery

Backstage pass over time is indeed a json object to the front desk how to become json string? ?

 

 

The picture shows the data string and json json object

 

Guess you like

Origin www.cnblogs.com/whl4835349/p/11592768.html