Avoid repeated names in json

0

I'm looking for a form / function / method so that it is not possible to repeat the value saved in Json, for example:

I'm saving the json below and I do not want it to save the same name in json.

[
  [
    {
      "id": "59a5c80dc75969297837c51e",
      "name": "uza",
      "password": "3648726"
    },
    {}
  ],
  [
    {
      "id": "59a5c811c75969297837c51f",
      "name": "kuza",
      "password": "3648726"
    },
    {}
  ],
  [
    {
      "id": "59a5c83ec75969297837c520",
      "name": "kuza",
      "password": "3648726"
    },
    {}
  ]
]

My code that creates the user in Json is this:

@api.route('/', methods=['POST'])
def create():

    # Pegar os dados da requisição
    user_json = request.get_json(silent=True)
    if not user_json:
        return "FAIL"

    # Criar uma entidade a partir do JSON
    user, errors = schema.load(user_json)
    if bool(errors):
        return jsonify(errors)
        user.save()
    return "SUCCESS"

Can you help me?

    
asked by anonymous 30.08.2017 / 15:56

0 answers