groovy get http parse json/xml

Hey i have this talk to do:

  • Use solr api, use this url: http://localhost:8983/solr/select/?q=tree
  • Get the answer via json/xml, deserialize it to a map objects

What is the best way to do that? I would like some hints on this. Thanks in advanced, RR

Ps. i searched for it in here, but i found examples too complex to understand.

Answers


Does:

def json = new JsonSlurper().parseText( new URL( 'http://localhost:8983/solr/select/?q=tree' ).text )

Get you to where you want to be?

Right, so this is Grails prior to 2.0, so can't use JsonSlurper as that needs Groovy 1.8+

Can you try:

def json = grails.converters.JSON.parse( new URL( 'http://localhost:8983/solr/select/?q=tree' ).text )

Need Your Help

Auto-rewrite URL in php

php function

I'm wondering if there is a pre-existing PHP function that will rewrite a given URL, adding a pre-defined application context. For example: I have a link like this:

How to assign the enter key on my keyboard to a JButton

java swing netbeans jframe

I have created a Jframe with a JButton for a specific action.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.