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

Can't use JavaScriptPrimitiveConverter for primitive values #2995

@hsreina

Description

@hsreina

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions