ruby-2.0.0 에서 ruby-2.1.1 로 바꾸는 과정
$rvm install ruby-2.1.1
$rvm use ruby-2.1.1
Gemfile edit
ruby '2.1.1'
$bundle
ruby '2.1.1'
install-package Newtonsoft.json(참고:visual studio 에서 package manager console ( install-package ) 사용하는 방법)
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Dim jsonString As String = "{""id"":1,""name"":""홍길동""}"직렬화 기능을 이용해 봅니다.
Dim jsonObject As JObject = JObject.Parse(jsonString) 'Object 만 파싱 한다.
Console.WriteLine("id:" & jsonObject.SelectToken("id").ToString)
Console.WriteLine("name:" & jsonObject.SelectToken("name").ToString)
Public Class Name
Public Property id
Public Property name
End Class
Dim jsonString As String = "{""id"":1,""name"":""홍길동""}"
Dim onename As Name = JsonConvert.DeserializeObject(Of Name)(jsonString)
Console.WriteLine("id:" & onename.id)
Console.WriteLine("name:" & onename.name)
Dim jsonString As String = "[{""id"":1,""name"":""홍길동""},{""id"":2,""name"":""임꺽정""}]"객체를 문자열로 변환합니다.
Dim nameList As List(Of Name) = JsonConvert.DeserializeObject(Of List(Of Name))(jsonString)
For Each onename As Name In nameList
Console.WriteLine("id:" & onename.id)
Console.WriteLine("name:" & onename.name)
Next
Console.WriteLine(JsonConvert.SerializeObject(nameList(0)))