Skip to content

Instantly share code, notes, and snippets.

@koduki
Last active March 11, 2020 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koduki/f848e3efa8fec95a1c823b15d627929d to your computer and use it in GitHub Desktop.
Save koduki/f848e3efa8fec95a1c823b15d627929d to your computer and use it in GitHub Desktop.
JSON文字列をList+HashMapに変換するコード。他言語に比べてちょっと冗長なのでメモ。
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.type.TypeReference;
var json = "[{\"name\":\"nanoha\", \"age\":10}, {\"name\":\"fate\", \"age\":10}]";
var mapper = new ObjectMapper();
var data = Arrays.asList(mapper.readValue(json, HashMap[].class));
System.out.println(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment