Created
April 21, 2022 07:05
-
-
Save AnarCom/0568a5206d644e7d4ac70fd03405b186 to your computer and use it in GitHub Desktop.
Parsing object from retejs serialization format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.core.type.TypeReference; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.util.Map; | |
import lombok.Data; | |
public class Main { | |
public static void main(String[] args) throws IOException { | |
var reader = new BufferedReader(new FileReader("./test.json")); | |
StringBuilder b = new StringBuilder(); | |
String line; | |
while ((line = reader.readLine()) != null) { | |
b.append(line); | |
} | |
String json = b.toString(); | |
NodeGroup a = new ObjectMapper().readValue(json, new TypeReference<NodeGroup>() { | |
}); | |
System.out.println("a"); | |
} | |
@Data | |
static class NodeGroup { | |
private String id; | |
private Map<String, Node> nodes; | |
} | |
@Data | |
static class Node { | |
private String id; | |
private Map<String, Object> data; | |
private String name; | |
private Integer[] position; | |
private Map<String, InputConnection> inputs; | |
private Map<String, OutputConnection> outputs; | |
} | |
@Data | |
static class InputConnection { | |
private InputConnectionData[] connections; | |
} | |
@Data | |
static class InputConnectionData { | |
private Integer node; | |
private String output; | |
private Map<String, Object> data; | |
} | |
@Data | |
static class OutputConnection { | |
private OutputConnectionData[] connections; | |
} | |
@Data | |
static class OutputConnectionData { | |
private Integer node; | |
private String input; | |
private Map<String, Object> data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment