Python String to JSON Array: Quick Conversion Guide

In Python, you can use the json module to convert a string into a JSON array. Here is an example code:

import json

# 定义一个JSON格式的字符串
json_str = '[{"name": "Alice", "age": 25}, {"name": "Bob", "age": 30}]'

# 将字符串转换为JSON数组
json_array = json.loads(json_str)

print(json_array)

By running the code above, you can convert a JSON-formatted string to a JSON array. The json.loads() function is used to convert a JSON-formatted string to a Python object.

bannerAds