2012-11-09 2 views
0

다음 json을 가지고 있습니다. 아래 json으로 인해 유효하지 않습니다. jsonically 유효하도록 문자열을 만들어야합니다. php에서 이것을 수행하는 가장 좋은 방법은 무엇입니까?JSON은 8 자리 숫자에 대한 문자열을 예상합니다. 따옴표로 묶는 방법

{ 
    29646191: [ 
     "https://www.facebook.com/RobertScoble/posts/480030845352725", 
     "https://sphotos-a.xx.fbcdn.net/hphotos-prn1/s480x480/546943_10151235934049655_1771118951_n.jpg", 
     "Today I tried... | Facebook", 
     "Robert Scoble wrote: Today I tried something. I paid $49 and... Join Facebook to connect with Robert Scoble and others you may know.", 
     null, 
     [ 
      "//images3-focus-opensocial.googleusercontent.com/gadgets/proxy?url\u003dhttps://sphotos-a.xx.fbcdn.net/hphotos-prn1/s480x480/546943_10151235934049655_1771118951_n.jpg\u0026container\u003dfocus\u0026gadget\u003da\u0026rewriteMime\u003dimage/*\u0026refresh\u003d31536000\u0026resize_h\u003d150\u0026resize_w\u003d150\u0026no_expand\u003d1", 
      150, 
      150, 
      null, 
      null, 
      null, 
      null, 
      null, 
      [ 
       3, 
       "https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url\u003dhttps://sphotos-a.xx.fbcdn.net/hphotos-prn1/s480x480/546943_10151235934049655_1771118951_n.jpg\u0026container\u003dfocus\u0026gadget\u003dhttps://plus.google.com\u0026rewriteMime\u003dimage/*\u0026resize_h\u003d800\u0026resize_w\u003d800\u0026no_expand\u003d1" 
      ] 
     ], 
     "//s2.googleusercontent.com/s2/favicons?domain\u003dwww.facebook.com", 
     [], 
     null, 
     [] 
    ] 
} 
+2

질문 제목에서 말했듯이, 숫자를 큰 따옴표로 묶으십시오. –

+1

형식이 지정된 코드를 요청하는 것이 그렇게 많은가요? – Daedalus

+0

네가하는 동안 해냈어, 너무 오래 걸려서 미안해. – Jay

답변

1

브라우저로 알려주세요.

var x = { 
    29646191: [ 
     "https://www.facebook.com/RobertScoble/posts/480030845352725", 
     "https://sphotos-a.xx.fbcdn.net/hphotos-prn1/s480x480/546943_10151235934049655_1771118951_n.jpg", 
     "Today I tried... | Facebook", 
     "Robert Scoble wrote: Today I tried something. I paid $49 and... Join Facebook to connect with Robert Scoble and others you may know.", 
     null, 
     [ 
      "//images3-focus-opensocial.googleusercontent.com/gadgets/proxy?url\u003dhttps://sphotos-a.xx.fbcdn.net/hphotos-prn1/s480x480/546943_10151235934049655_1771118951_n.jpg\u0026container\u003dfocus\u0026gadget\u003da\u0026rewriteMime\u003dimage/*\u0026refresh\u003d31536000\u0026resize_h\u003d150\u0026resize_w\u003d150\u0026no_expand\u003d1", 
      150, 
      150, 
      null, 
      null, 
      null, 
      null, 
      null, 
      [ 
       3, 
       "https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url\u003dhttps://sphotos-a.xx.fbcdn.net/hphotos-prn1/s480x480/546943_10151235934049655_1771118951_n.jpg\u0026container\u003dfocus\u0026gadget\u003dhttps://plus.google.com\u0026rewriteMime\u003dimage/*\u0026resize_h\u003d800\u0026resize_w\u003d800\u0026no_expand\u003d1" 
      ] 
     ], 
     "//s2.googleusercontent.com/s2/favicons?domain\u003dwww.facebook.com", 
     [], 
     null, 
     [] 
    ] 
} 

JSON.stringify(x); 

"{"29646191을 제공합니다 ": ["https://www.facebook.com/RobertScoble/posts/480030845352725 ","HTTPS : //sphotos-a.xx합니다. fbcdn.net/hphotos-prn1/s480x480/546943_10151235934049655_1771118951_n.jpg ", 오늘 오늘은 나는 시도했다 ... | 페이스 북 ","로버트 스코 블 (Robert Scoble)은 다음과 같이 적었다. $ 49를 지불하고 ... Robert Scoble 및 다른 사람들과 연결할 Facebook에 가입하면 알 수 있습니다. ", null, ["// images3-focus-opensocial.googleusercontent.com/gadgets/proxy?url=https:/ /sphotos-a.xx.fbcdn.net/hphotos-prn1/s480x480/546943_10151235934049655_1771118951_n.jpg 용기 = & & 가제트 = A = & rewriteMime 이미지/* & 리프레시 = 31,536,000 초점 resize_h & & resize_w = 150 = 150 = 1 & no_expand ", 150,150, null, null, null, null, null, [3,"https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url=https://sphotos-a.xx.fbcdn. net/hphotos-prn1/s480x480/546943_10151235934049655_1771118951_n.jpg & 컨테이너 = 포커스 & 가젯 = https : //plus.google.c OM = & rewriteMime 이미지/* = 800 resize_h & & & resize_w = 800 no_expand = 1 "]"// s2.googleusercontent.com/s2/favicons?domain=www.facebook.com",[],null, []]} "

+0

php에서 JSON.stringify 대신 json_encode를 사용하는 경우 – Oxi

+0

json_Encode는 작동하지만 결합 배열을 가져 오지 않습니다. 도움이 될 경우 더 많은 코드가 적용되는 곳으로 전자 메일을 보낼 수 있습니다. – Jay

관련 문제