K-Mile
08-21-2007, 06:02 PM
Hi,
I've been running into problems with my JSON code becoming bloated. We use spring.net with ASP.NET AJAX integration. The thing is, that when I send a 'User' with basic information set down the line, the JSON becomes something like:
{
Id: 42,
Name: "John Doe,
Address: null,
PhoneNumber: null,
Password: null,
FavoriteFood: null
}
Well, you get the picture. When I populate a list, I don't need all that extra info, but it is sent anyway. I would like to make a filter that skips all 'null' properties. Our javascript code is set up in such a way that we never rely on the difference between 'null' and 'undefined', so we should be alright there.
I am thinking of creating a simple stream rewriter in ANTLR3, that skips all properties with value 'null'. This should be implemented after ASP.NET AJAX and WebServiceExporter are finished with their processing, but I am not sure where to hook into ASP.NET. The AJAX library provides some configuration, but creating a custom converter for every domain object we have is quite tedious, so I'd rather let ASP.NET AJAX and spring.net do the heavy lifting and then filter the output.
Any thoughts on where to start? All I am looking for is the right hook point to get a string or stream with the generated JSON, but haven't been able to find it yet.
Thanks
I've been running into problems with my JSON code becoming bloated. We use spring.net with ASP.NET AJAX integration. The thing is, that when I send a 'User' with basic information set down the line, the JSON becomes something like:
{
Id: 42,
Name: "John Doe,
Address: null,
PhoneNumber: null,
Password: null,
FavoriteFood: null
}
Well, you get the picture. When I populate a list, I don't need all that extra info, but it is sent anyway. I would like to make a filter that skips all 'null' properties. Our javascript code is set up in such a way that we never rely on the difference between 'null' and 'undefined', so we should be alright there.
I am thinking of creating a simple stream rewriter in ANTLR3, that skips all properties with value 'null'. This should be implemented after ASP.NET AJAX and WebServiceExporter are finished with their processing, but I am not sure where to hook into ASP.NET. The AJAX library provides some configuration, but creating a custom converter for every domain object we have is quite tedious, so I'd rather let ASP.NET AJAX and spring.net do the heavy lifting and then filter the output.
Any thoughts on where to start? All I am looking for is the right hook point to get a string or stream with the generated JSON, but haven't been able to find it yet.
Thanks