/*
 * Examples for Java
 *
 * Copyright (c) 2021. Elex. All Rights Reserved.
 * https://www.elex-project.com/
 */

package kr.pe.elex.examples;

import com.elex_project.abraxas.Console;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class GsonSample {

	public static void main(String... args){
		Gson gson = new GsonBuilder().create();

		// to json
		Person charlie = new Person("Charlie", 13);
		String json = gson.toJson(charlie);
		Console.writeLine(json);

		// from json
		Person steve = gson.fromJson("{'name':'Steve', 'age':43}", Person.class);
		Console.writeLine(steve);
	}


}
