Home  >  Q&A  >  body text

html - flask background passes a null to the front end

The flask backend passes the value to the front-end javascript and passes a null, such as ['Global',null,0,0]. If you use str to pass it, it will be ['Global','null',0,0], yes What can I do?

扔个三星炸死你扔个三星炸死你2675 days ago898

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-06-22 11:53:24

    In the standard JSON format, the null value is included.

    Python’s JSON library can parse null values ​​normally.

    https://docs.python.org/3/lib...

    >>> import json
    >>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
    '["foo", {"bar": ["baz", null, 1.0, 2]}]'
    

    will parse None to null.

    And the front-end’s JSON.parse can handle null values ​​normally.

    reply
    0
  • Cancelreply