[sf-perl] REST data parsing

mehryar mehryar at mehryar.com
Tue Sep 7 17:49:24 PDT 2010


I don't think REST says anything about the format of data being exchanged.

The below looks like malformed JSON to me. Missing an opening curly after 
"FraudCheckMonitorResults". But otherwise you should be able to parse it 
via some json module.

cheers,
-Mehryar


On Tue, 7 Sep 2010, David Alban wrote:

> greetings,
>
> i know little about REST.  i've been told that this example string is
> rest data, something returned by some RESTful process:
>
> {"FraudCheckMonitorResults":"TrinityCheck":1,"AccertifyCheck":1,"NumRetryListings":1,"NumRetryOrders":1,"NumPurchasedStuckOrders":1,"NumAcceptedListings":1,"NumAcceptedOrders":1,"NumRejectedListings":1,"NumRejectedOrders":1,"NumReviewedListings":1,"NumReviewedOrders":1}}
>
> a local java developer asked me (the local perl guy) how to get this
> string into a perl data structure.  when i asked, he confirmed he
> wanted something like this:
>
> FraudCheckMonitorResults => {
>  TrinityCheck            => 1,
>  AccertifyCheck          => 1,
>  NumRetryListings        => 1,
>  NumRetryOrders          => 1,
>  NumPurchasedStuckOrders => 1,
>  NumAcceptedListings     => 1,
>  NumAcceptedOrders       => 1,
>  NumRejectedListings     => 1,
>  NumRejectedOrders       => 1,
>  NumReviewedListings     => 1,
>  NumReviewedOrders       => 1,
> };
>
> i was about to code it when i asked if this was a standard data
> format, thinking why should i reinvent this particular wheel?  maybe
> cpan has something.  i was told it was REST data.  but my impressive
> lack of knowledge about REST is not helping.  i took a brief look on
> search.cpan.org.  i'll keep looking, but i haven't found anything yet
> that looks like it might deal with the kind of string above.
>
> questions:
>
> * is the string at the top of the email REST data?
> * if so, are there cpan libraries with routines that will parse these
> kind of strings, resulting in the kind of data structures shown above?
>
> thanks,
> david
> --
> Live in a world of your own, but always welcome visitors.
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
>


More information about the SanFrancisco-pm mailing list