将JSON添加到数据表

时间:2019-07-02 06:53:10

标签: php json vb.net

我试图将PHP脚本生成的JSON添加到VB.net数据表中,但是JSON的格式不正确(缺少双引号)。

PHP:

 header('Content-type: text/html; charset=utf8');
 $conn = mysqli_connect();
 $query = mysqli_query($conn, "SELECT * FROM installations where hwid = '".$_GET["hwid"]."'");
 while($row = mysqli_fetch_assoc($query)) {
 $data[] = $row;
 }

 echo htmlspecialchars(json_encode($data), ENT_QUOTES, 'UTF-8');
 json_last_error_msg();
 ?>

生成此JSON,该JSON缺少附加的双引号:

 [{"idinstallations":"9","hwid":"74D435E5185A","naziv_racunala":"DESKTOP-0U5","naziv_instalacije":"prip","adresa_instalacije":"Vel","ukupno_artikala":"152","ukupno_dokumenata_d":"3","ukupno_dokumenata_arh":"0","ukupno":"20.50","prva_instalacija":"2019-06-14 05:25:45","licenca":"0","Opis_opa":"beb tipo","lastContact":"2019-06-30 14:05:43","version":"1.0.0.4\/a","dnevnik_summ":"20,50","arhiva_summ":"0","mod":"1","sync":"0","syncing":"","toMail":"xxx.ttt@gmail.com","licExpire":null,"teamviewer":""}]

这是我用来将JSON设置为数据表的VB.net代码:

Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString(http://www.something.com)
Dim json As String = result
Dim table As DataTable = JsonConvert.DeserializeObject(Of DataTable)(json)

0 个答案:

没有答案