Yet another parsing Json question

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Yet another parsing Json question

Most
This post was updated on .
I am trying to take some Json from one site, parse it and send the parsed data to another but I'm getting stuck on the parsing it seems. I looked at your previous explanation and the source code but am unable to figure it out. Here is my sample.


val location = "path/dir"
val history = "file"
val req = :/("example.com")

  // Parses the Json
object Capture extends dispatch.json.Js {
  val sample1 = 'sample1 ? num
  val sample2 = 'sample2 ? num
  val sample3 = 'sample3 ? str
  val sample4 = 'sample4 ? str
}

val answer = http(req / location / history ># (list ! obj))


Running this I'm getting this error.

java.lang.RuntimeException: Extractor dispatch.json.Js$list$$anon$1 does not match JSON:

I know it's properly formatted Json so it's me, any help would be appreciated.

Reply | Threaded
Open this post in threaded view
|

Re: Yet another parcing Json question

n8han
Administrator
That error indicates that it did parse but not into the expected elements, that the json was something other than a list of objects.

Nathan


On Mar 21, 2010, at 12:23 AM, Most [via Databinder] wrote:

I am trying to take some Json from one site, parce it and send the parced data to another but I'm getting stuck on the parcing it seems. I looked at your previous explanation and the source code but am unable to figure it out. Here is the sample.


val location = "path/dir"
val history = "file"
val req = :/("example.com")

  // Parces the Json
object Weather extends dispatch.json.Js {
  val sample1 = 'sample1 ? num
  val sample2 = 'sample2 ? num
  val sample3 = 'sample3 ? str
  val sample4 = 'sample4 = str

val answer = http(req / location / history ># (list ! obj))


Running this I'm getting this error.

java.lang.RuntimeException: Extractor dispatch.json.Js$list$$anon$1 does not match JSON:

I know it's properly formatted Json so it's me, any help would be appreciated.




View message @ http://n2.nabble.com/Yet-another-parcing-Json-question-tp4771435p4771435.html
To start a new topic under Databinder, email [hidden email]
To unsubscribe from Databinder, click here.


Reply | Threaded
Open this post in threaded view
|

Re: Yet another parcing Json question

Most
We guessed that but figured it was something else as the Json file has a valid format, interesting, the console shows that it is getting the right file. Thank you for the help.
Reply | Threaded
Open this post in threaded view
|

Re: Yet another parcing Json question

Randin
I tried parsing and got the same error but was able to get the lift framework to work have you took a look at that?
Reply | Threaded
Open this post in threaded view
|

Re: Yet another parcing Json question

n8han
Administrator
Yes, and I would recommend that you use it through dispatch-lift-json if you find it easier to work with:
http://dispatch.databinder.net/Lift-JSON

Nathan

On Mar 23, 2010, at 18:44 , Randin [via Databinder] wrote:

I tried parsing and got the same error but was able to get the lift framework to work have you took a look at that?


View message @ http://n2.nabble.com/Yet-another-parsing-Json-question-tp4771435p4787700.html
To start a new topic under Databinder, email [hidden email]
To unsubscribe from Databinder, click here.


Reply | Threaded
Open this post in threaded view
|

Re: Yet another parcing Json question

Most
In reply to this post by Randin
Sadly no, we cannot use that, looking at your message thread I looked at your Json and ours is the same format albeit not as big so we will have to keep trying, maybe you needed to single out the data array? Did you try that?
Reply | Threaded
Open this post in threaded view
|

Re: Yet another parcing Json question

Randin
Probably not correctly, I'm learning as I go really so I most likely did not, any suggestions would be welcome.