1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How do I type annotate JSON data in Python?

Discussão em 'Python' iniciado por Stack, Setembro 9, 2025.

  1. Stack

    Stack Membro Participativo

    I am adding type annotations to a lot of code to make it clear to other devs what my functions and methods do. How would I type annotate a function that takes JSON data in as an argument, and returns JSON data?

    (very simplified version)

    def func(json_data):
    return json_data


    what I want to do but with JSON instead of int:

    def add_nums(a: int, b: int) -> int:
    return a+b

    Continue reading...

Compartilhe esta Página