Skip to content

Different field_name on different object returned #358

Open
@Dvergatal

Description

@Dvergatal

I am currently struggling with a difficult problem to solve. because what i want to do is to prepare a data class for azure cloud to i.e. update device attestation.

The problem which I'm facing is that a sample request for i.e. Symmetric Key looks like this:

{
  "type": "symmetricKey",
  "symmetricKey": {
    "primaryKey": "<primary key>",
    "secondaryKey": "<secondary key>"
  }
}

as you can see in another json code block for i.e. TPM:

{
  "type": "tpm",
  "tpm": {
    "endorsementKey": "<endorsement key>"
  }
}

you can see that the second field changes according to the name of class. Now I have these classes written and have a factory function returning, specified by this first type variable, object. The problem which I'm facing is that the name of this object in json is the name of variable not the name of the returned object type. I was thinking of using this field_name parameter from the field module, in order to change it's name but it's not possible, or maybe i dunno how to do that, to change it depending on the returned object type.

I would be pleased if somebody might have a solution for this use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions