Bug 4148

Summary: JavaScriptSerializer invalid json primitive
Product: [Mono] Class Libraries Reporter: Alex Sinm <sinmsinm>
Component: System.WebAssignee: marcos.henrich
Severity: normal CC: brendon_ferris, kris.krause, kumpera, mono-bugs+mono, mz
Priority: ---    
Version: 2.10.x   
Target Milestone: Untriaged   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Fix the crash at jsondeserializer parsing keywords with trailing spaices

Description Alex Sinm 2012-03-29 08:11:39 UTC
JavaScriptSerializer.Deserialize throws invalid json primitive exception
Comment 1 Alex Sinm 2012-03-29 08:12:19 UTC
class foo {public bool bar;}
void test() {
    string foo_json = "{\"bar\" : true\n}";
    foo foo_obj = (new JavaScriptSerializer).Deserialize<foo>(foo_json);

Throws "Invalid json primitive : true" while there is trailing whitespace just after the 'true'.
Comment 2 Salvador Alemany 2013-02-18 05:45:26 UTC
Created attachment 3403 [details]
Fix the crash at jsondeserializer parsing keywords with trailing spaices

It's still posible trigger the bug with the current stable release. 

My attachment fix the bug in a very simple way. If mono developers are interested in the patch they can use it.
Comment 3 joe 2014-11-20 08:41:27 UTC
This seems to still be a problem in the latest release.  For example

{"test":true } will fail due to the whitespace following the boolean.  When will this patch be added to the main source?
Comment 4 Rodrigo Kumpera 2015-04-14 12:38:43 UTC
Hey Marcos,

Could you review & merge this fix?
Comment 5 marcos.henrich 2015-04-16 14:20:54 UTC
Hi Alex, Salvador, Joe,

Thank you for the bug report.

The pull request for this issue can be found in the link below.
Comment 6 marcos.henrich 2015-04-19 09:47:49 UTC
Fixed in mono master 3fa9d4d5c920ef4c67a99240d6f23bb1340159b5.
Comment 7 mz 2015-08-05 03:44:35 UTC
Any chance this fix would be included in am acutal released version?
Currently it's only available in master.
Comment 8 marcos.henrich 2015-08-10 12:23:30 UTC
Hi mz,

This will be included on mono 4.2 release.