2016-06-24 15 views
0

テキストを正規化しようとしています。私は自分のWebサイトからWoocommerce CMSを使用しています。GET応答後に文字列の分割機能が機能しない

製品 ":[{" タイトル ":" INTERMECのPC43TのUSB Barkod YAZの\ u0131cのの\ u0131" 、 "ID":369、 "はcreated_at": "2016-01-24T02この文字列のどのような「タイプ」:「シンプル」、「ステータス」:「公開」、「ダウンロード可能」:偽、「仮想」:偽、 "sku": ""、 "price": "239"、 "regular_price": "239"、 "sale_price":null、 "price_html": "$ 239,00 </span>"、 "taxable" "tax_status": "課税"、 "tax_class": ""、 "managing_stock":偽、 "stock_quantity":ヌル、 "IN_STOCK":真、 "backorders_allowed":偽、...私はcouldn

値を1つずつ引っ張ったり、この文字列を正規化したりすることはありません。しかし、文字列は機能しませんでした。例えば、私が試した:

Dim product As String = wac.GetAllProducts() ' Get data from WoocommerceApiClient 
product.ToArray() 
Dim normalized As String() = Split(product, ",", , CompareMethod.Text) 
Console.WriteLine(normalized) 

...と

Dim normalized As String() = Split(product, """", , CompareMethod.Text) 

は私が0N1GlcZDZCFbQXa5w3GZlCSG3CNbbgxYHZzbNRiZG6k = 可能System.String []

私は、これらの文字列を正規化するにはどうすればよい

のような出力に何かを得ましたか。私はまた、その部分(プロパティと値)を取得する必要があります。

+5

。 – jmcilhinney

+0

はい、私はNewtonsoft Jsonを使用して、問題を解決しました。どうもありがとう。 – onurcano22

答えて

0

私はNewtonsoft Jsonを使用しました。問題を解決したので、これはsimple json parse methodです。ここに私の最終的なコードです:

Imports Newtonsoft.Json 
Imports Newtonsoft.Json.Linq 

...あなたはそれを解析するJSON.NETのようなツールを使用することができるはずですので、むしろJSONのように見える

Dim line = wac.GetProducts() 

Dim json As String = line.ToString() 

Dim ser As JObject = JObject.Parse(json) 
Dim data As List(Of JToken) = ser.Children().ToList 

For Each item As JProperty In data 
    item.CreateReader() 
    Select Case item.Name 
     ' Case "products" 
     '  MessageBox.Show(item.Name) 
     Case "products" 
      For Each msg As JObject In item.Values 

       Dim product_id As String = msg("id") 
       Dim product_title As String = msg("title") 
       Dim product_price As String = msg("price") 
       products_dgv.Rows.Add(product_id, product_title, product_price) 


      Next 
    End Select 
Next 
関連する問題