From 804bbc93b7d061b46588eeb9a7d776b007c4c5b9 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Sat, 26 May 2018 16:59:09 -0700 Subject: [PATCH] Make JSON models less strict --- CHANGES.md | 1 + server/src/rbx.rs | 4 ++++ test-project/src/hello.model.json | 8 ++------ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 82cb68dc..5e18cae7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ ## Current master * Fixed warning when renaming or removing files that would sometimes corrupt the instance cache (#72) +* JSON models are no longer as strict -- `Children` and `Properties` are now optional. ## 0.4.8 (May 26, 2018) * Hotfix to prevent errors from being thrown when objects managed by Rojo are deleted diff --git a/server/src/rbx.rs b/server/src/rbx.rs index f411242f..14d3b8cd 100644 --- a/server/src/rbx.rs +++ b/server/src/rbx.rs @@ -6,7 +6,11 @@ use std::collections::HashMap; pub struct RbxInstance { pub name: String, pub class_name: String, + + #[serde(default = "Vec::new")] pub children: Vec, + + #[serde(default = "HashMap::new")] pub properties: HashMap, /// The route that this instance was generated from, if there was one. diff --git a/test-project/src/hello.model.json b/test-project/src/hello.model.json index bc707e8d..c0afd96f 100644 --- a/test-project/src/hello.model.json +++ b/test-project/src/hello.model.json @@ -4,14 +4,11 @@ "Children": [ { "Name": "Some Part", - "ClassName": "Part", - "Children": [], - "Properties": {} + "ClassName": "Part" }, { "Name": "Some StringValue", "ClassName": "StringValue", - "Children": [], "Properties": { "Value": { "Type": "String", @@ -19,6 +16,5 @@ } } } - ], - "Properties": {} + ] } \ No newline at end of file