From 822a1b15285449e46d21e3dbbf7dc2dde593d9a1 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Sun, 16 Apr 2023 00:27:00 +0200 Subject: [PATCH] JSON: Transmit the ID as a string. See commit for the reason. --- .../fritteli/labyrinth/generator/renderer/json/Generator.java | 2 +- .../labyrinth/generator/renderer/json/JsonRenderer.java | 2 +- src/main/resources/labyrinth.schema.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/fritteli/labyrinth/generator/renderer/json/Generator.java b/src/main/java/ch/fritteli/labyrinth/generator/renderer/json/Generator.java index 09e69b1..c0cb8cc 100644 --- a/src/main/java/ch/fritteli/labyrinth/generator/renderer/json/Generator.java +++ b/src/main/java/ch/fritteli/labyrinth/generator/renderer/json/Generator.java @@ -20,7 +20,7 @@ class Generator { @NonNull JsonLabyrinth generate() { final JsonLabyrinth result = new JsonLabyrinth(); - result.setId(this.labyrinth.getRandomSeed()); + result.setId(String.valueOf(this.labyrinth.getRandomSeed())); result.setWidth(this.labyrinth.getWidth()); result.setHeight(this.labyrinth.getHeight()); final List> rows = new ArrayList<>(); diff --git a/src/main/java/ch/fritteli/labyrinth/generator/renderer/json/JsonRenderer.java b/src/main/java/ch/fritteli/labyrinth/generator/renderer/json/JsonRenderer.java index e2b3fe2..335f9c5 100644 --- a/src/main/java/ch/fritteli/labyrinth/generator/renderer/json/JsonRenderer.java +++ b/src/main/java/ch/fritteli/labyrinth/generator/renderer/json/JsonRenderer.java @@ -39,7 +39,7 @@ public class JsonRenderer implements Renderer { rows.get(0).add(cell); // Wrap it all in an instance of JsonLabyrinth. final JsonLabyrinth jsonLabyrinth = new JsonLabyrinth(); - jsonLabyrinth.setId(0L); + jsonLabyrinth.setId("0"); jsonLabyrinth.setGrid(rows); return jsonLabyrinth; } diff --git a/src/main/resources/labyrinth.schema.json b/src/main/resources/labyrinth.schema.json index b5be24b..e81ce01 100644 --- a/src/main/resources/labyrinth.schema.json +++ b/src/main/resources/labyrinth.schema.json @@ -12,8 +12,8 @@ ], "properties": { "id": { - "type": "integer", - "existingJavaType": "java.lang.Long" + "type": "string", + "description": "64 bit precision signed integer value. Transmitted as string, because ECMAScript (browsers) don't normally handle 64 bit integers well, as the ECMAScript 'number' type is a 64 bit signed double value, leaving only 53 bits for the integer part, thus losing precision." }, "width": { "type": "integer", -- 2.45.2