Skip to content

Instantly share code, notes, and snippets.

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.List;
public class NullSer {
public static void main(String[] args) {
String json = "[{\n" +
" \"id\":\"1\",\n" +
import com.google.gson.*;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.*;
import java.util.stream.Collectors;
import java.util.*;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
public class Stuff {
public static void main(String[] args) {
Stream<Integer> input = Stream.of(1, 1, 1, 2, 2, 2, 3, 6, 7, 7, 1, 1);
@alexcrt
alexcrt / RS.java
Last active August 29, 2015 14:20
public class RS {
public static void main(String[] args) throws FileNotFoundException {
Type t = new TypeToken<List<RateInfo>>(){}.getType();
Gson gson = new GsonBuilder().registerTypeAdapter(t, new RSDeserializer()).create();
TopLevel topLevel = gson.fromJson(new FileReader(new File("test.json")), TopLevel.class);
System.out.println(topLevel);
}
}
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.*;
public class MapToJson {
public static void main(String[] args) {
Map<Wrapper ,Boolean> map = new HashMap<>();
map.put(new Wrapper(new String[]{"Hello"}),false);
map.put(new Wrapper(new String[]{"Stack", "Overflow"}), true);
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.*;
import java.lang.reflect.Type;
import java.util.*;
public class Parsing {
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Stream;
import static java.util.stream.Collectors.*;
public class Stats {
import com.google.gson.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
public class Json {
public static void main(String... args) throws FileNotFoundException {
Gson gson = new Gson();
import com.google.gson.*;
import com.google.gson.annotations.SerializedName;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.lang.reflect.Type;
import java.util.Collection;
/**
import java.util.*;
import static java.util.stream.Collectors.*;
import java.util.stream.Stream;
/**
* Created by alex on 23.02.15.
*/
public class MessagesQuery {
public static void main(String... args) {
Collection<Message> myCombinedCollection = getList();