Nancy
Nancy copied to clipboard
Can't use JavaScriptPrimitiveConverter for primitive values
Prerequisites
- [X] I have written a descriptive issue title
- [X] I have verified that I am running the latest version of Nancy
- [X] I have verified if the problem exist in both
DEBUG
andRELEASE
mode - [ ] I have searched open and closed issues to ensure it has not already been reported
Description
I'm not able to use Custom Primitive Converters (JavaScriptPrimitiveConverter) on types string, IEnumerable, numeric and boolean. Why is it called JavaScriptPrimitiveConverter if we can't do it? I'm maybe just don't understand how it should work.
Funny thing is JavaScriptPrimitiveConverter seem to be used in the function jsonSerializerStrategy.TrySerializeNonPrimitiveObject in SimpleJson.cs
Steps to Reproduce
Create a custom JavaScriptPrimitiveConverter like this one referenced here https://github.com/NancyFx/Nancy/wiki/Sample-JavaScriptPrimitiveConverter Register it with JsonConfiguration.Default.PrimitiveConverters.Add(new ByteArrayAsBase64Converter());
System Configuration
- Nancy version: 2.0.0
- Nancy host
- [ ] Nancy.Hosting.Aspnet
- [X] Nancy.Hosting.Self
- [ ] Nancy.Owin ()
- [ ] Other:
- Other Nancy packages and versions:
- Environment (Operating system, version and so on): Windows 10 x86_64(dev), RaspberryPi arm 32bits(runtime)
- .NET Framework version:
- Additional information: Code location hint: SerializeValue in SimpleJson.cs. I just want a discussion on how to do that without replacing the full serializer first. I'm trying to emulate an api that do something stupid so I need to do the same stupid thing. All numeric values except float from their api are converted to string when serilized to json.