- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
JSON.parse bug
Mon, 2010-04-12, 20:37
Hi,
scala> JSON.parseFull("[]")
res1: Option[Any] = Some(Map())
Should be: res1: Option[Any] = Some(List())
scala> JSON.parseFull("[{\"a\":{}}]")
res4: Option[Any] = Some(List(Map(a -> Map())))
scala> JSON.parseFull("[{\"a\":[]}]")
res5: Option[Any] = Some(List(Map(a -> Map())))
Should be:
res5: Option[Any] = Some(List(Map(a -> List())))
scala> JSON.parseFull("[{\"a\":[1,2,3]}]")
res2: Option[Any] = Some(List(Map(a -> List(1.0, 2.0, 3.0))))
scala> JSON.parseFull("[{\"a\":[]}]")
res3: Option[Any] = Some(List(Map(a -> Map()))
the problem is in scala.util.parsing.json.Parser class that looses
information whether list or object was parsed.
Fix (attached to ticket) is trivial but makes JSON api backward
incompatible, unless different parsers will be used for method
JSON.parse and method JSON.parseFull. Actually the JSON.parseFull method
looks like attempt to fix problem with result of JSON.parse method. But
that approach does not work in generic case. It does not work with empty
lists emitting empty map instead (see last two REPL lines)
Thu, 2010-05-27, 22:47
#2
Re: Re: JSON.parse bug
On 05/27/2010 02:57 PM, Vladimir Kirichenko wrote:
> Vladimir Kirichenko wrote:
>> https://lampsvn.epfl.ch/trac/scala/ticket/3284
>
>
>> A revised patch that won't break the build is ready to commit, but will
> be held until after 2.8 final comes out to avoid last-minute breakages.
>
> Does this mean that 2.8 final will contain known buggy code making JSON
> parser hardly useful?
>
I'm not putting that patch in while we're in RC status without Martin's
approval, so you would have to appeal to him. I've added the patch as an
attachment to the ticket in case you want to apply it yourself.
Derek
Thu, 2010-05-27, 23:37
#3
Re: Re: JSON.parse bug
Derek Chen-Becker wrote:
>> Does this mean that 2.8 final will contain known buggy code making JSON
>> parser hardly useful?
>>
>
> I'm not putting that patch in while we're in RC status without Martin's
> approval, so you would have to appeal to him.
Let's do that :)
> I've added the patch as an
> attachment to the ticket in case you want to apply it yourself.
It's not a problem not to use it, I'm using own copy of patched
JSONParser code now. Just concerning about scala:) If it's not going to
be applied for 2.8 that means that scala2.8 will have no working JSON
parser, just broken one. And the nature of this bug, as you saw,
requires API changes, so 2.8 will have broken API in release too.
Thu, 2010-05-27, 23:57
#4
Re: Re: JSON.parse bug
On 05/27/2010 04:29 PM, Vladimir Kirichenko wrote:
> It's not a problem not to use it, I'm using own copy of patched
> JSONParser code now. Just concerning about scala:) If it's not going to
> be applied for 2.8 that means that scala2.8 will have no working JSON
> parser, just broken one. And the nature of this bug, as you saw,
> requires API changes, so 2.8 will have broken API in release too.
>
>
I don't disagree with this assessment, but if there's a possibility that
the API changes I've made would break something else (and my first
commit attempt did!) then I would rather wait until 2.8.1. Call me
paranoid, but I'm really not looking to break the build twice in a row.
Derek
Vladimir Kirichenko wrote:
> https://lampsvn.epfl.ch/trac/scala/ticket/3284
>A revised patch that won't break the build is ready to commit, but will
be held until after 2.8 final comes out to avoid last-minute breakages.
Does this mean that 2.8 final will contain known buggy code making JSON
parser hardly useful?