NancyFx / Nancy

Lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono
http://nancyfx.org
MIT License
7.16k stars 1.47k forks source link

Can't use JavaScriptPrimitiveConverter for primitive values #2995

Open hsreina opened 4 years ago

hsreina commented 4 years ago

Prerequisites

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