vb .net json 처리

.net 2016. 8. 8. 12:20
{
  • "rtncode":"200",
  • "msg":"성공",
  • "data":[
    1. {
      • "no":"56525",
      • "section":"1",
      • "category":"88",
      • "subject":"복지부, "지자체 사회보장제도 동의 비율 증가""
      }
      ,
    2. {
      • "no":"56524",
      • "section":"1",
      • "category":"88",
      • "subject":"양천구,"소리 없이 찾아오는 ‘뼈 도둑’, 조기검진 필수""
      }
      ,
    3. {
      • "no":"56523",
      • "section":"1",
      • "category":"88",
      • "subject":"수입 미국산 밀과 밀가루에서 미승인 유전자변형 밀 불검출"
      }
      ,
    4. {
      • "no":"56520",
      • "section":"1",
      • "category":"88",
      • "subject":"서울특별시동부병원, ‘아트앤프렌즈展’ 전시회 개최"
      }
    ]
}
이런 json 처리 과정

install-package Newtonsoft.json -> 비주얼스튜디오->도구->패키지 관리자->패키지 콘솔에서 설치

imports 추가

Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq

처리 내용 아래 과정

Else
   Try
            Dim wresp As WebResponse
            Dim wreq As WebRequest = HttpWebRequest.Create("http://www.test.com/api/new_api.com")
            Dim str As String = ""
            wresp = wreq.GetResponse()

            Using sr As New StreamReader(wresp.GetResponseStream())
                str = sr.ReadToEnd()
                sr.Close()
            End Using


            Dim jsonstring As String = str
            Dim json_results As New System.Net.Json.JsonTextParser
            Dim j_result As System.Net.Json.JsonObjectCollection
            Dim ser As JObject = JObject.Parse(jsonstring)


            j_result = json_results.Parse(jsonstring)
            Dim jj_string As String = j_result("data").ToString
            Dim data As List(Of JToken) = ser.Children().ToList
            Dim output As String = ""

            For Each item As JProperty In data
                item.CreateReader()
                Select Case item.Name
                    Case "data"

                        For Each comment As JObject In item.Values
                            Dim news_no As String = comment("no")
                            Dim news_subject As String = comment("subject")
                            Dim news_category As String = comment("category")
                            Dim news_section As String = comment("section")

                            ListBox1.Items.Add("· " & news_subject)
                            output = "/news/view.html?section=" & news_section & "&category=" & news_category & "&no=" & news_no
                            news_list_link.Add(output)

                        Next

                End Select
            Next

        Catch ex As Exception
            MsgBox(ex.Message, "가져오기 실패")
        End Try
End If


'.net' 카테고리의 다른 글

vb net 파일 쓰기 삭제 생성  (0) 2016.06.15
vb net 웹 브라우져 연결  (0) 2016.05.18
vb .net 웹페이지 xml 데이터 처리  (0) 2016.05.11
vb 웹 페이지 소스 가져오기  (0) 2016.05.10
vb net 스프레드 크기 조정  (0) 2016.04.18
Posted by 몽키 D.루피
,

$exchange_url="http://api.fixer.io/latest?base=HKD";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $exchange_url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1000);

$rt = curl_exec($ch);

curl_close($ch);

// var_dump(json_decode($rt));


$hwan_api = json_decode($rt);


$hwan_krw = $hwan_api->rates->KRW;


//echo $hwan_krw;



그외 

http://fx.kebhana.com/FER1101M.web


외환은행 환율 api



' > php' 카테고리의 다른 글

php 개월 차이 구하기  (0) 2016.12.02
정규표현식 문자사이 삭제  (0) 2016.10.07
php 랜덤 문자열 숫자 생성 함수  (0) 2016.07.14
php ftp를 통한 업로드시 안될경우  (0) 2016.07.11
코드이그나이터 엑셀 설정  (0) 2016.05.31
Posted by 몽키 D.루피
,

jsp db 연동 connect

웹/java 2016. 7. 26. 13:44

mysql-connector-java-5.1.38 폴더 속 mysql-connector-java-5.1.38-bin << 요놈을 

WebContent >WEB-INF> lib 에 복.

없으면 설치하기 ↓

http://dev.mysql.com/downloads/connector/j

* Java Build Path 확인

 mysql-connector-java-5.1.38-bin << 요놈을 java jdk있는 곳에 복.붙

저같은 경우는

D:\Sue\java\jre.1.8.0_77\lib\ext << 이경로..






<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR" %> <%@ page import = "java.sql.*" %> <!-- JSP에서 JDBC의 객체를 사용하기 위해 java.sql 패키지를 import 한다 --> <% Connection conn = null; //초기화 try{ String url = "jdbc:mysql://localhost:3306/test"; // URL, "jdbc:mysql://localhost:3306/(mySql에서 만든 DB명)" << 입력 이때 3306은 mysql기본 포트 String id = "root"; // SQL 사용자 이름 String pw = "1234"; // SQL 사용자 패스워드 Class.forName("com.mysql.jdbc.Driver"); // DB와 연동하기 위해 DriverManager에 등록한다. conn=DriverManager.getConnection(url,id,pw); // DriverManager 객체로부터 Connection 객체를 얻어온다. out.println("연결됨"); // 커넥션이 제대로 연결되면 수행된다. }catch(Exception e){ // 예외 처리 e.printStackTrace(); } %>

Posted by 몽키 D.루피
,