samedi 24 octobre 2020

Need some help translating a get value in a JSON file

Our school receives data from a source during a sync.

I'm familiar with JavaScript but would like to ask for a litle help before I make a change.

Here is the scenario: The source sending the information to us has the default value as "tobedeleted". We need this to be translated to "inactivate". and then put into our DB.

What's being sent I think is simply ignored because it doesn't match any of our enum values.

My idea is to get help writing: if the get value = "tobedeleted" then translate it to "inactivate" and then update our database.

            {
              "paramType": "query",
              "name": "task",
              "description": "The action to take on the enrollment.\nWhen inactive, a user will still appear in the course roster to admins, but be unable to participate.\n(\"inactivate\" and \"deactivate\" are equivalent tasks)",
              "type": "string",
              "format": null,
              "required": false,
              "deprecated": false,
              "enum": [
                "conclude",
                "delete",
                "inactivate", //<--- "tobedeleted" needs to be "inactivate"
                "deactivate"
              ]
            }

Thank you in advance!

Aucun commentaire:

Enregistrer un commentaire