我尝试获取数据的API如下所示" https://repositery-api.appication-pp.ag/v10/repositeries/?page=0&size=1"
我试图以JSON格式获取数据的铁python代码是
import clr
clr.AddReference('System.Data')
clr.AddReference('System.Web.Extensions')
import System
from System import DateTime
from System.Data import DataSet, DataTable
from System.IO import StreamReader, StreamWriter, MemoryStream, SeekOrigin
from System.Net import HttpWebRequest
from System.Web.Script.Serialization import JavaScriptSerializer
from System import String, Int32, Single, Double
from Spotfire.Dxp.Data import DataType, DataTableSaveSettings
from Spotfire.Dxp.Data.Import import TextFileDataSource, TextDataReaderSettings
# get data in JSON format
uri = "https://repositery-api.appication-pp.ag/v10/repositeries/?page=0&size=1"
print uri
webRequest = HttpWebRequest.Create(uri)
response = webRequest.GetResponse()
streamReader = StreamReader(response.GetResponseStream())
jsonData = streamReader.ReadToEnd()
js = JavaScriptSerializer()
js.MaxJsonLength = Int32.MaxValue;
**dataDict = js.Deserialize(jsonData,object)**
我收到错误说"无效的JSON原语:。" 来自代码的最后一行。 有人可以看看这个并帮助我
示例数据:
{
"data": [
{
"a": "CHEMISTRY",
"b": 1,
"c": "Hc",
"d": 12345,
"d": "k7t3h0t-jk78-0bnp-0t25-7fg5335gf78b",
"e": {
"f": "95366",
"g": "57998",
"h": "BALKIJ",
"i": ""
},
"j": {
"k": 1389,
"l": "2004-11-25T10:96:41Z",
"j": "balkij",
"k": "CHEMISTRY ",
"l": 12345,
"e": {
"m": "574.0",
"n": "3",
"o": " BALKIJ ",
"p": "ERR098",
"q": "jdnd kskd"
},
"r": false
},
"s": null,
"t": 96652,
"u": "98852",
"v": null,
"w": null,
"x": "2004-11-25T10:96:67Z ",
"y": "hjjn",
"z": false
}
]
}