Skip to content

.net 6 broken migration JsonElement to dynamic #66517

Closed
@devopg

Description

@devopg

I come from .net core 2.1 and after migration to .net 6 i got different behavior.

I have json in my RabbitMQ. After cunsume new message i deserialize to class with field List

class msg{
   public string Name {get;set;}
   public int Old {get;set;}
   ... other fiedls 
   public List<dynamic> list {get;set;}
}

Working code from 2.1 now throw error

    foreach (var i in msg.list)
    {
        switch ((VariantEnum)i.variant)

In debug i found that now "var i" is typeof JsonElement

How i can in .net 6 use dynamic like before ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Text.Jsonneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions