Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread SuperObject user needed
Mon, May 11 2015 8:43 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

I'm trying, and failing, to use SuperObject to analyse the results from OMDB search. I can find lots of examples for SuperObject, most of which seem to think you understand SuperObject to start with.

IO've been able to figure out the simple stuff such as extracting data from a single film eg

{"Title":"Serenity","Year":"2005","Rated":"PG-13","Released":"30 Sep 2005","Runtime":"119 min","Genre":"Action, Adventure, Sci-Fi","Director":"Joss Whedon","Writer":"Joss Whedon","Actors":"Nathan Fillion, Gina Torres, Alan Tudyk, Morena Baccarin","Plot":"In the future, a spaceship called Serenity is harboring a passenger with a deadly secret. Six rebels on the run. An assassin in pursuit. When the renegade crew of Serenity agrees to hide a fugitive on their ship, they find themselves in an awesome action-packed battle between the relentless military might of a totalitarian regime who will destroy anything - or anyone - to get the girl back and the bloodthirsty creatures who roam the uncharted areas of space. But, the greatest danger of all may be on their ship.","Language":"English, Mandarin","Country":"USA","Awards":"8 wins & 5 nominations.","Poster":"http://ia.media-imdb.com/images/M/MV5BMTI0NTY1MzY4NV5BMl5BanBnXkFtZTcwNTczODAzMQ@@._V1_SX300.jpg","Metascore":"74","imdbRating":"8.0","imdbVotes":"220,163","imdbID":"tt0379786","Type":"movie","Response":"True"}

But when it has a lot of results as below I'm stuck.


{"Search":[{"Title":"Serenity","Year":"2005","imdbID":"tt0379786","Type":"movie"},{"Title":"Done the Impossible: The Fans' Tale of 'Firefly' and 'Serenity'","Year":"2006","imdbID":"tt0838164","Type":"movie"},{"Title":"Sci Fi Inside: 'Serenity'","Year":"2005","imdbID":"tt0482592","Type":"movie"},{"Title":"Serenity: The 10th Character","Year":"2003","imdbID":"tt0865524","Type":"movie"},{"Title":"Serenity","Year":"1999","imdbID":"tt0323926","Type":"movie"},{"Title":"The Other Side of Serenity","Year":"1998","imdbID":"tt0175014","Type":"movie"},{"Title":"Serenity's Roman Orgy","Year":"2002","imdbID":"tt0313575","Type":"movie"},{"Title":"Serenity in Denim","Year":"1999","imdbID":"tt0217793","Type":"movie"},{"Title":"Serenity","Year":"2008","imdbID":"tt1365647","Type":"movie"},{"Title":"Temptation of Serenity","Year":"1994","imdbID":"tt0152974","Type":"movie"}]}


Roy Lambert
Mon, May 11 2015 9:46 AMPermanent Link

Matthew Jones

Roy Lambert wrote:

>  I can find lots of examples for SuperObject, most of which seem to
> think you understand SuperObject to start with.

You may have seen my request for JSON parsers on the Embarcadero
newsgroups, and I gave superobject a go, but likewise found it hard to
make it really work. In the end I went with lkJSON because it is simple
object code, and nothing fancy. Not perfect, but it worked for me.

--

Matthew Jones
Mon, May 11 2015 11:14 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Matthew


I had forgotten that, just refreshed my memory by rereading.

I have downloaded lkJSON, if you think it can do what I want I'll have a go - the demos that came with it don't give me any help Frown

My fallback is I'll ask for the results in xml - that I know I can parse!

However, the more I stare at the JSON produced, have a look at the structure definition, and ignore "It is easy for humans to read and write" the more I realise I don't need any super swift parser or anything. This is going to get used a bit, never intensively and I can easily drag stuff out.


Roy Lambert
Mon, May 11 2015 11:34 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Matthew


As the saying goes "bloody hell"

I was trawling to see if I could find documentation for Tiny-JSON, found https://github.com/thomaserlang/delphi-json and the example he gave for yet another JSON parser was exactly what I wanted. Smile

Roy Lambert
Mon, May 11 2015 11:34 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Just for anyone interested - this is all I needed

procedure TForm1.Button1Click(Sender: TObject);
var
Obj: ISuperObject;
itm:  ISuperObject;
begin
Obj := SO(Memo1.lines.Text);
for itm in Obj['Search'] do showmessage(itm['Title'].AsString);
end;

OK now I have to do something with it rather than just stick it on screen.


Roy Lambert
Mon, May 11 2015 11:36 AMPermanent Link

Matthew Jones

Roy Lambert wrote:

> However, the more I stare at the JSON produced

There is nothing better than jsonlint.com for both checking that you
have good JSON, and making it look structured so you can understand it.

I just had a look at my utility file, and see that I decided to
abstract the code for my purposes, so I can change it any time I want.
I'll email it to you so you can compare. I will include the superobject
version I never completed...

--

Matthew Jones
Mon, May 11 2015 11:38 AMPermanent Link

Matthew Jones

Roy Lambert wrote:

> I was trawling to see if I could find documentation for Tiny-JSON,
> found https://github.com/thomaserlang/delphi-json and the example he
> gave for yet another JSON parser was exactly what I wanted. Smile

I think I liked that one, but it is a parser only, so cannot build or
change the JSON for creating new.

--

Matthew Jones
Mon, May 11 2015 2:49 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Matthew


>There is nothing better than jsonlint.com for both checking that you
>have good JSON, and making it look structured so you can understand it.

Nice - that does make it readable - I've added it to my favourites.

Roy
Mon, May 11 2015 2:56 PMPermanent Link

Raul

Team Elevate Team Elevate

On 5/11/2015 2:49 PM, Roy Lambert wrote:
>> There is nothing better than jsonlint.com for both checking that you
>> have good JSON, and making it look structured so you can understand it.
>
> Nice - that does make it readable - I've added it to my favourites.

i like http://json.parser.online.fr/ personally - allows you to
experiment on the left

Raul
Tue, May 12 2015 2:51 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Raul


Nice - added that as well

Roy Lambert
Page 1 of 2Next Page »
Jump to Page:  1 2
Image