Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 테스트 자동화
- Koin
- MediaSession
- node.js
- SwiftUI Tutorial
- SWIFTUI
- android13
- mvvm
- Kotlin
- Reactive
- Android
- rx
- Android 13
- PagingLib
- junit
- Observable
- RxKotlin
- node
- Animation
- MotionLayout
- list
- paging
- databinding
- 동영상
- MediaPlayer
- php
- google play
- GCP
- mysql
- 인앱결제
Archives
- Today
- Total
봄날은 갔다. 이제 그 정신으로 공부하자
JSON String 파싱하는 방법 본문
1. ObjectMapper 사용
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
String jsonString = "{"id":12345,"name":"tester001"}";
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(jsonString);
Integer id = rootNode.get("id").asInt();
String name = rootNode.get("name").asText();
2. Gson 사용
import com.google.gson.Gson;
String jsonString = "{"id":12345,"name":"tester001”}”;
Gson gson = new Gson();
JsonObject json = gson.fromJson(jsonString, JsonObject.class)
Integer id = json.get("id").getAsInt();String name = json.get("name").getAsString();
3. Gson 사용 2
@Setter
@Getter
@Builder
public class UserInfo {
private Integer id;
private String name;
}
String jsonString = "{"id":12345,"name":"tester001"}";
Gson gson = new Gson();
UserInfo userInfo = gson.fromJson(jsonString, UserInfo.class)'학습' 카테고리의 다른 글
| [PHP] cURL (0) | 2025.12.01 |
|---|---|
| JpaRepository DB 조회 방법 (0) | 2025.11.17 |
| node.js로 웹서비스 만들기 (24. 서버 다운 문제 대응) (1) | 2023.08.28 |
| node.js로 웹서비스 만들기 (23. Compute Engine 일정 관리) (0) | 2023.08.27 |
| node.js로 웹서비스 만들기 (22. Compute Engine 재 시작시 서비스 자동 실행하기) (1) | 2023.08.25 |
Comments