jdegoes/blueeyes — Issue #32: How to emit JSON for a class?
Author: mslinn
Created: 2011-11-08 00:44:43+00:00
State: open

I'd like to be able to convert this class into JSON so it could be assigned to a JValue:

````
case class TextMatch(val workCellRef:ActorRef, val length:Int = 0, val startPos:Int = 0, val endPos:Int = 0)
````

The JSON would look like this:

````
{
"TextMatch": {
"workCellRef":"opaqueStuff", "length":123, "startPos":234, "endPos":456
}
}
````

How can I do this?

I also need to turn a list of ````TextMatch```` objects into JSON, perhaps something like the following. Again, how would I do that so the list could be assigned to a JValue?

````
{
[
"TextMatch": {
"workCellRef":"opaqueStuff", "length":123, "startPos":234, "endPos":456
},
"TextMatch": {
"workCellRef":"opaqueStuff", "length":123, "startPos":234, "endPos":456
},
"TextMatch": {
"workCellRef":"opaqueStuff", "length":123, "startPos":234, "endPos":456
},
]
}
````

Thanks,

Mike