Skip to content

How to deal with Microsoft.Kiota.Abstractions.Serialization.Untyped* instances #2422

Answered by andrueastman
stefanboerner asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for raising this @stefanboerner

Ideally, the model should be defined in the metadata as type so that it shows up as a strongly typed property. However, since this is only known at runtime, you can probably parse this as below.

private static void ParseUnknownObject(UntypedNode untypedNode, string indent = "")
{
    switch (untypedNode)
    {
        case UntypedObject untypedObject:
            Console.WriteLine(indent + "Found object value: ");
            var properties = untypedObject.GetValue();
            foreach (var (name, node) in properties)
            {
                Console.WriteLine(indent + "Property Name: " + name);
                ParseUnknownObject(node, indent + "

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by stefanboerner
Comment options

You must be logged in to vote
1 reply
@stefanboerner
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants