Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
97
rated 0 times [  104] [ 7]  / answers: 1 / hits: 16201  / 11 Years ago, tue, november 26, 2013, 12:00:00
       json= new Gson().toJson(name);


where name is of type string.



I am getting error saying TypeError: invalid 'in' operand obj



error is in the given part of java script



 return type === array || type !== function &&
( length === 0 ||
typeof length === number && length > 0 && ( length - 1 ) in obj );


I have also tried



   response=JSON.parse(response); 


which is not working.


More From » jquery

 Answers
25

by link In operator you can see that




The in operator returns true if the specified property is in the specified object.




in your code ( length - 1 ) in obj you try checking that property (length - 1) that numeric in your obj



I think obj is a string, so it has the length property, but does not have numeric properties, so you must catch this case


[#74061] Monday, November 25, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tobyl

Total Points: 598
Total Questions: 110
Total Answers: 114

Location: Vietnam
Member since Sat, Feb 12, 2022
2 Years ago
;