Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Anyone have problems parsing JSON?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
pgio  
View profile  
 More options Mar 25 2011, 2:30 am
From: pgio <pete.giovagn...@gmail.com>
Date: Thu, 24 Mar 2011 23:30:07 -0700 (PDT)
Local: Fri, Mar 25 2011 2:30 am
Subject: Anyone have problems parsing JSON?
Specifically I'm trying to decode the signed_request that Facebook
returns from its Registration plugin. Splitting it into its two parts
and running debase64() on the second part works, though the resulting
string ends up with an extra quote mark. The result looks like JSON
but the parseJSON() method always returns false. It's definitely a
string, it looks well-formed, but it won't parse. Any ideas? Facebook
uses Base64Url encoding, might that gave something to do with it?

Pete


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Oberhammer  
View profile  
 More options Mar 25 2011, 4:13 am
From: Simon Oberhammer <simon.oberham...@gmail.com>
Date: Fri, 25 Mar 2011 01:13:50 -0700 (PDT)
Local: Fri, Mar 25 2011 4:13 am
Subject: Re: Anyone have problems parsing JSON?

Hi Pete,
can you post the JSON string you have trouble with?

You can try a browser's native JSON.parse() or jsonlint.com to verify the
string is valid JSON.

greetings
 simon


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pgio  
View profile  
 More options Mar 25 2011, 11:49 am
From: pgio <pete.giovagn...@gmail.com>
Date: Fri, 25 Mar 2011 08:49:02 -0700 (PDT)
Local: Fri, Mar 25 2011 11:49 am
Subject: Re: Anyone have problems parsing JSON?
Sure. Here's the response from Facebook after split(), debase64() and
unwrap():

                {"algorithm":"HMAC-SHA256","expires":0,"issued_at":
1301030795,"oauth_token":"134488113278066
97196677e182b97d171eb039-1005861684
aKEPt10NIgkOrOMDESJgTqWsCcw","registration":{"name":"Pete
Giovagnoli","first_name":"Pete","last_name":"Giovagnoli","email":"pgio
\u0040earthlink.net"},"registration_metadata":
{"fields":"name,first_name,last_name,email"},"user":
{"country":"us","locale":"en_US"},"user_id":"xxxxxxxxxxxx"} "

Notice there's substantial whitespace before and after the string. And
I redacted my Facebook ID.

Minus the whitespace and the last quote mark this passes the JSON
parser at http://json.parser.online.fr/
I thought unwrap() would remove the newlines in this chunk of text but
it doesn't seem to do much. Curious.

Thanks  Simon.

On Mar 25, 3:13 am, Simon  Oberhammer <simon.oberham...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Oberhammer  
View profile  
 More options Mar 25 2011, 12:00 pm
From: Simon Oberhammer <simon.oberham...@gmail.com>
Date: Fri, 25 Mar 2011 17:00:13 +0100
Local: Fri, Mar 25 2011 12:00 pm
Subject: Re: [helma] Re: Anyone have problems parsing JSON?
are you sure you aren't cutting the json in half when you do the
split()? maybe facebooks does base64(JSON.stringify(obj)). thus if you
first split, then debase64() and finally parse() you will end up with
broken JSON.

i wouldn't do unwrap() - linebreaks are fine in json.

this is how i did it: http://pastebin.com/DpmMy39B

 simon


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pgio  
View profile  
 More options Mar 25 2011, 12:49 pm
From: pgio <pete.giovagn...@gmail.com>
Date: Fri, 25 Mar 2011 09:49:33 -0700 (PDT)
Local: Fri, Mar 25 2011 12:49 pm
Subject: Re: Anyone have problems parsing JSON?
Facebook returns a Base64Url string in two parts separated by a
period, so I split on that, so that shouldn't be the problem. (The
first part is an encoded hash I think.) As I said the string above
comes out after the split().debase64() combo.

I found a jar that does Base64 and Base64u and I dropped that into my
installation and tried to patch modules/core/String.js with a new
method to use it, but I keep getting type errors when I try to invoke
the functions that are supposed to be exposed.

It's an interesting problem.
Thanks,
Pete

On Mar 25, 11:00 am, Simon Oberhammer <simon.oberham...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pgio  
View profile  
 More options Mar 25 2011, 6:54 pm
From: pgio <pete.giovagn...@gmail.com>
Date: Fri, 25 Mar 2011 15:54:11 -0700 (PDT)
Local: Fri, Mar 25 2011 6:54 pm
Subject: Re: Anyone have problems parsing JSON?
HA! Got it. It's definitely the Base64Url encoding. When I figured out
how to wrap a Java library that handled base64u, I patched the String
prototype with a new method and got the Facebook stuff decoded
correctly. parseJSON() now spits out a proper JSON object.

The library is at http://mindprod.com/products1.html#BASE64

Thanks,
Pete


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »