As Danny Dainton has already pointed out, JSON.parse(responseBody)
and
pm.response.json()
do the same thing - they both return the response body
of your API request as a string in JSON format.
Concerning the missing const
declaration in the second statement. - If you
put the two statements in the same file, then clearly you are correct to
leave out the const
declaration in the second statement.
(Otherwise there will be a syntax error: Identifier 'json_response' has already been declared
.)
But since the two statements do the same thing, it makes no sense to have
them both in the same script.
And if they are not in the same script, a declaration is necessary in the
second statement as well as in the first.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…