JSON을 처리하는 방법이 몇가지가 있는데 Go처럼 구조체에 맵핑하는 방식이 있다.

Go는 구조체 필드에 태그를 다는 태깅이 가능한데 JSON 파서가 이 필드의 태그를 읽어 맵핑한다.

하지만 재미있게도 이 태그를 통한 접근은 오직 Reflection 패키지를 이용해야만 가능하다. 이 과정에서 필드에 접근하는데, 이거부터가 Unsafe한 대입 연산을 허용시켜준다.

2

If you have a fediverse account, you can quote this note from your own instance. Search https://hackers.pub/ap/notes/019849cb-cca2-7085-872a-d4c9e803a244 on your instance and quote it. (Note that quoting is not supported in Mastodon.)