# Game fails to process valid JSON?

**URL:** <https://discourse.cataclysmdda.org/t/game-fails-to-process-valid-json/22922>\
**Category:** The Toolbox\
**Created:** [March 1, 2020, 1:25pm UTC](https://discourse.cataclysmdda.org/t/game-fails-to-process-valid-json/22922 "2020-03-01T13:25:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Firebrand](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/firebrand/32/6020_2.png) [@Firebrand](https://discourse.cataclysmdda.org/u/Firebrand)\
**Post date:** [March 1, 2020, 1:25pm UTC](https://discourse.cataclysmdda.org/t/game-fails-to-process-valid-json/22922/1 "2020-03-01T13:25:30Z")

</div>

I can’t load [my own mod](https://github.com/FirebrandCoding/HomesteadInstrumentsInc) because [one of the files](https://github.com/FirebrandCoding/HomesteadInstrumentsInc/blob/de8f28aec984b9ea1361d21be0d35d500986dc26/furniture/servers.json) is not being parsed by the game due to the following error (from `debug.log`):

```auto
20:04:00.996 ERROR : (error message will follow backtrace)
  #0
    (dbghelp: @0x7e68c6[cataclysm-tiles.exe+0x3e68c6]), 
    (libbacktrace: Z21debug_write_backtraceRSo+0x56@0x7e68c6),
    (libbacktrace: 0x7e68c6 [unknown src]:0 [unknown func]),
  #1
    (dbghelp: @0x7e735a[cataclysm-tiles.exe+0x3e735a]), 
    (libbacktrace: Z8DebugLog10DebugLevel10DebugClass+0x34a@0x7e735a),
    (libbacktrace: 0x7e735a [unknown src]:0 [unknown func]),
  #2
    (dbghelp: @0x7ea076[cataclysm-tiles.exe+0x3ea076]), 
    (libbacktrace: Z12realDebugmsgPKcS0_S0_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x76@0x7ea076),
    (libbacktrace: 0x7ea076 [unknown src]:0 [unknown func]),
  #3
    (dbghelp: IMG_LoadWEBP_RW+0x11bed4@0x18bbb44[cataclysm-tiles.exe+0x14bbb44]), 
    (libbacktrace: Z12realDebugmsgIJPKcEEvS1_S1_S1_S1_DpOT_+0x344@0x18bbb44),
    (libbacktrace: 0x18bbb44 [unknown src]:0 [unknown func]),
  #4
    (dbghelp: @0xccfe73[cataclysm-tiles.exe+0x8cfe73]), 
    (libbacktrace: ZN9main_menu17new_character_tabEv+0x1f33@0xccfe73),
    (libbacktrace: 0xccfe73 [unknown src]:0 [unknown func]),
  #5
    (dbghelp: @0xcd4bba[cataclysm-tiles.exe+0x8d4bba]), 
    (libbacktrace: ZN9main_menu14opening_screenEv+0x87a@0xcd4bba),
    (libbacktrace: 0xcd4bba [unknown src]:0 [unknown func]),
  #6
    (dbghelp: IMG_LoadWEBP_RW+0x912654@0x20b22c4[cataclysm-tiles.exe+0x1cb22c4]), 
    (libbacktrace: main+0x1524@0x20b22c4),
    (libbacktrace: 0x20b22c4 [unknown src]:0 [unknown func]),
  #7
    (dbghelp: @0x4013ed[cataclysm-tiles.exe+0x13ed]), 
    (libbacktrace: _tmainCRTStartup+0x23d@0x4013ed),
    (libbacktrace: 0x4013ed /home/narc/src/mxe/tmp-gcc-x86_64-w64-mingw32.static/gcc-5.4.0.build_/mingw-w64-v5.0.2/mingw-w64-crt/crt/crtexe.c:336 __tmainCRTStartup),
  #8
    (dbghelp: @0x4014fb[cataclysm-tiles.exe+0x14fb]), 
    (libbacktrace: WinMainCRTStartup+0x1b@0x4014fb),
    (libbacktrace: 0x4014fb /home/narc/src/mxe/tmp-gcc-x86_64-w64-mingw32.static/gcc-5.4.0.build_/mingw-w64-v5.0.2/mingw-w64-crt/crt/crtexe.c:186 WinMainCRTStartup),
  #9
    (dbghelp: BaseThreadInitThunk+0x14@0x7ffd2a5381f4[KERNEL32.DLL+0x181f4]), 
    (backtrace_syminfo failed: errno = -1, msg = no symbol table in PE/COFF executable),
    (backtrace_pcinfo failed: errno = -1, msg = no debug info in PE/COFF executable),
  #10
    (dbghelp: RtlUserThreadStart+0x21@0x7ffd2cf0a251[ntdll.dll+0x6a251]), 
    (backtrace_syminfo failed: errno = -1, msg = no symbol table in PE/COFF executable),
    (backtrace_pcinfo failed: errno = -1, msg = no debug info in PE/COFF executable),
Backtrace emission took 0 seconds.
src/main_menu.cpp:781 [bool main_menu::new_character_tab()] Error: data/mods//HomesteadInstrumentsInc/furniture/servers.json: line 1:1: Expected string or array

[
^

  {
    "type": "furniture",

```

As you can see, the game points at the array and says it’s not “string or array” as it expected.

I have the JSON structure checked manually and with [two](https://jsonformatter.curiousconcept.com/) different [validators](https://jsonlint.com/): [result 1](https://i.imgur.com/mmAexYy.png), [result 2](https://i.imgur.com/BuCaRjG.png) (under the code window). All JSON editors I’ve used to so far also parse it perfectly, providing collapsing of sections as expected and yielding no errors.

What do?

---

<div class="post-metadata">

**Author:** ![MrSelfDestruct](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mrselfdestruct/32/8122_2.png) [@MrSelfDestruct](https://discourse.cataclysmdda.org/u/MrSelfDestruct)\
**Post date:** [March 1, 2020, 3:28pm UTC](https://discourse.cataclysmdda.org/t/game-fails-to-process-valid-json/22922/2 "2020-03-01T15:28:33Z")

</div>

> [@Firebrand](#):
>
> ```auto
> src/main_menu.cpp:781 [bool main_menu::new_character_tab()] Error: data/mods//HomesteadInstrumentsInc/furniture/servers.json: line 1:1: Expected string or array
> 
> ```

I haven’t programmed much in CDDA, but the way this is worded maybe it can’t parse JSONs that use tabulators instead of spaces. This shouldn’t be a case with most JSON parsers, but it’s just a thought, because I don’t actually know for sure what this error may mean.

---

<div class="post-metadata">

**Author:** ![anothersimulacrum](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/anothersimulacrum/32/10770_2.png) [@anothersimulacrum](https://discourse.cataclysmdda.org/u/anothersimulacrum)\
**Post date:** [March 1, 2020, 4:53pm UTC](https://discourse.cataclysmdda.org/t/game-fails-to-process-valid-json/22922/3 "2020-03-01T16:53:05Z")

</div>

Something about the second furniture object in that file causes it to fail. Removing that allows it to load to the next error (missing construction id).

---

<div class="post-metadata">

**Author:** ![anothersimulacrum](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/anothersimulacrum/32/10770_2.png) [@anothersimulacrum](https://discourse.cataclysmdda.org/u/anothersimulacrum)\
**Post date:** [March 1, 2020, 4:58pm UTC](https://discourse.cataclysmdda.org/t/game-fails-to-process-valid-json/22922/4 "2020-03-01T16:58:30Z")

</div>

Looking at it further, `copy-from` is the problematic bit. Removing it and adding back the missing mandatory members allows it to load that file. After that, you can then add back `copy-from` and it loads that file.

---

<div class="post-metadata">

**Author:** ![Firebrand](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/firebrand/32/6020_2.png) [@Firebrand](https://discourse.cataclysmdda.org/u/Firebrand)\
**Post date:** [March 1, 2020, 5:00pm UTC](https://discourse.cataclysmdda.org/t/game-fails-to-process-valid-json/22922/5 "2020-03-01T17:00:59Z")

</div>

That’s one hell of a thorough look you gave it. Thanks a lot!

Could you elaborate on the `copy-from` bit and how it affects loading? I thought I had the required parts defined for the second object: `id`, `type`, `name`, and `description`, right?

---

<div class="post-metadata">

**Author:** ![anothersimulacrum](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/anothersimulacrum/32/10770_2.png) [@anothersimulacrum](https://discourse.cataclysmdda.org/u/anothersimulacrum)\
**Post date:** [March 1, 2020, 5:07pm UTC](https://discourse.cataclysmdda.org/t/game-fails-to-process-valid-json/22922/6 "2020-03-01T17:07:52Z")

</div>

```auto
diff --git a/furniture/servers.json b/furniture/servers.json
index 5768a21..442ee60 100644
--- a/furniture/servers.json
+++ b/furniture/servers.json
@@ -42,6 +42,10 @@
     "type": "furniture",
     "id": "f_server_working",
     "copy-from": "f_server",
+ "symbol": ":",
+ "color": "blue_white",
+ "move_cost_mod": -1,
+ "required_str": 1,
     "name": "server stack (working)",
     "description": "This is a rack full of compact computer devices. The indicator lights are shining and flickering. Can be used in extensive computations.",
     "//": "emits a little light due to the I/O lights",
@@ -59,4 +63,4 @@
       ]
     }
   }
-]
\ No newline at end of file
+]

```

This is my diff to make it load.  
The newline at the end of the file isn’t necessary.  
Removing any of these (with the exception of `color`) causes the same issue you got, and not having color gives an error that you need either `color` or `bgcolor`

---

<div class="post-metadata">

**Author:** ![Firebrand](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/firebrand/32/6020_2.png) [@Firebrand](https://discourse.cataclysmdda.org/u/Firebrand)\
**Post date:** [March 1, 2020, 5:29pm UTC](https://discourse.cataclysmdda.org/t/game-fails-to-process-valid-json/22922/7 "2020-03-01T17:29:29Z")

</div>

Just tested it. Works like a charm. Thanks a lot!

---

<div class="post-metadata">

**Author:** ![lexicalpedant](https://avatars.discourse-cdn.com/v4/letter/l/e95f7d/32.png) [@lexicalpedant](https://discourse.cataclysmdda.org/u/lexicalpedant)\
**Post date:** [March 8, 2020, 4:07am UTC](https://discourse.cataclysmdda.org/t/game-fails-to-process-valid-json/22922/8 "2020-03-08T04:07:27Z")

</div>

Missing symbols are causing issues with most of the Homestead items now, though the Project-Apex files seem to have included them.

Also I didn’t find this thread until after I’d already dealt with the issue you have here, that copy-from error had me stuck for a good while, I ended up making the same changes as anothersimulcrum through blind luck, just comparing your furniture defs to known working mods.

Hope you keep working on these they look promising!

---

<div class="post-metadata">

**Author:** ![Firebrand](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/firebrand/32/6020_2.png) [@Firebrand](https://discourse.cataclysmdda.org/u/Firebrand)\
**Post date:** [March 9, 2020, 1:49pm UTC](https://discourse.cataclysmdda.org/t/game-fails-to-process-valid-json/22922/9 "2020-03-09T13:49:40Z")

</div>

> [@lexicalpedant](#):
>
> until after I’d already dealt with the issue

You’re not saying you’re using Homestead for your own mods, are you? It hasn’t even seen its first release yet.
