Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Can't use JavaScriptPrimitiveConverter for primitive values #2995

Open
4 of 8 tasks
hsreina opened this issue Nov 25, 2019 · 0 comments
Open
4 of 8 tasks

Can't use JavaScriptPrimitiveConverter for primitive values #2995

hsreina opened this issue Nov 25, 2019 · 0 comments

Comments

@hsreina
Copy link

hsreina commented Nov 25, 2019

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of Nancy
  • I have verified if the problem exist in both DEBUG and RELEASE 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
    • 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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant