2015년 11월 27일 금요일

jQuery에서 문자열을 json 객체로 변환시...


parseJSON 을 사용하면 되는 건 맞는데!!! 주의 할 점!!!

문서 대강대강 보다가.. 2시간 날림..!!

문자열 만들때..


1
2
var obj = jQuery.parseJSON( '{ "name": "John" }' );
alert( obj.name === "John" );

반드시!!! 쌍따옴표를 써야 한다.. javascript여서.. 홑따옴표로 변형해서 썼더니 절대 안됐음..

설명을 잘 읽어 볼걸......

Passing in a malformed JSON string results in a JavaScript exception being thrown. For example, the following are all invalid JSON strings:
  • "{test: 1}" (test does not have double quotes around it).
  • "{'test': 1}" ('test' is using single quotes instead of double quotes).
  • "'test'" ('test' is using single quotes instead of double quotes).
  • ".1" (a number must start with a digit; "0.1" would be valid).
  • "undefined" (undefined cannot be represented in a JSON string; null, however, can be).
  • "NaN" (NaN cannot be represented in a JSON string; direct representation of Infinity is also not permitted).

댓글 없음:

댓글 쓰기

[PS2] 악마성 2개 클리어 일지..

https://www.youtube.com/watch?v=HwFIH--7UkM PS2 버전 악마성 시리즈 전부 클리어.. 순수의 비가는 카메라 구도 조정이 전혀 안되서.. 정말 어려웠는데.. 어둠의 저주는 전작의 여러 부족한 부분을 개선하여.. 쾌적하...