Skip to content

untyped objects deserialised by System.Text.Json are unsupprted #591

Description

@nhunt-zf

untyped objects with nested data deserialised by Newtonsoft can be used successfully with handlebars.net
consider:

var json = "{\"A\": {\"B\" : \"b\"}}";
object a = Newtonsoft.Json.JsonConvert.DeserializeObject(json)!;
string value = Handlebars.Create().Compile("{{A.B}}")(a);

value would be "b" (assuming I have no typos in the code.

However the same code won't work on an untyped object deserialised by System.Text.Json

object a = System.Text.Json.JsonSerializer.Deserialize<object>(json)!;
string value = Handlebars.Create().Compile("{{A.B}}")(a);

value will be "".

It would be great if the complex object deserialised by System.Text.Json could be used in handlebars templates, as per Newtonsoft.

Newtonsoft is not a part of the .NET standard library offering, and it would be good if Handlebars.NET worked well with the core libraries.

One key limitation that we have encountered is that untyped objects deserialised by Newtonsoft can't themselves be reliably serialised and deseriasied by the default .NET serialisation mechanism. This limits our ability to use Newtonsoft in our solution, and therefore we require native untyped object JSON support by handlebars.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions