Skip to content

Deserialising JSON with variable property names #26

@TAGC

Description

@TAGC

I'm trying to deserialise a JSON document containing variable field names, and I'm unsure how to do this using JKI JSON.

For example, consider the following document:

{
    "abs_bar": {
        "messageId": 500,
        "canPort": 1,
        "repeatRate": 50
    },
    "foo": {
        "messageId": 10,
        "canPort": 0,
        "repeatRate": 50
    }
}

I don't know the fields of the document in advance - I'd like to deserialise this to a dictionary where the key is the "message definition name" and the value is a "message definition" cluster, and go from there. I've been able to do this pretty easily in Python and C#, but unfortunately LabVIEW is not a very nice language and most things take a lot more effort in it.

LabVIEW does not have the native concept of a "map", so I attempted to deserialise this as an array of clusters, where each cluster contains a string (for the name) and a "message definition" cluster.

json deserialisation snippet

I didn't really expect this to work and it doesn't seem to. This is what I see on the front panel after running this:

image

What's the proper way to go about this?

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