Gson은 구글에서 만든 json구조의 데이터를 JAVA의 객체로 만들어주기 위해 사용하는 자바 라이브러리입니다.
Gson 다운로드
아래 링크에 들어가 원하는 버전을 누릅니다. (저는 2.8.9 버전을 사용하였습니다.)
https://mvnrepository.com/artifact/com.google.code.gson/gson

jar 파일 다운

다운 받고 압축을 풀어준 뒤
JavaProject 마우스 우클릭 → Properties →
JavaBuildPath → ModulePath에 jar 파일을 열고 적용해주면 됩니다.
복잡한 데이터를 파싱해야 할 때 유용하게 쓸 수 있는 jsonschema2pojo
https://www.jsonschema2pojo.org/
jsonschema2pojo
Reference properties For each property present in the 'properties' definition, we add a property to a given Java class according to the JavaBeans spec. A private field is added to the parent class, along with accompanying accessor methods (getter and sette
www.jsonschema2pojo.org
우선 파싱하고자 하는 내용을 붙여넣어 줍니다.
그 다음 Package와 Class name을 적어주고,
Source type은 JSON으로, Annotation style은 None으로, Validation annotations None으로 설정합니다.

그 다음 Zip으로 압축 파일을 만들어 압축을 풀어주고 넣고 싶은 패키지에 해당 파일을 복사 붙여넣으면 됩니다.

'프로그래밍 > Json' 카테고리의 다른 글
Json_com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ (0) | 2023.03.16 |
---|---|
Json_Json 가상데이터 파싱 (0) | 2023.03.15 |