changeset 450:3f220c2b4076

add: shortcut for loading of json files
author Sam <sam@basx.dev>
date Sat, 09 Mar 2024 23:06:27 +0700
parents 9e621b1116b9
children 05dd71c246a3
files semicongine/resources.nim
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/resources.nim	Sat Mar 09 20:30:08 2024 +0700
+++ b/semicongine/resources.nim	Sat Mar 09 23:06:27 2024 +0700
@@ -1,4 +1,5 @@
 import std/streams
+import std/json
 import std/algorithm
 import std/strutils
 import std/sequtils
@@ -179,6 +180,9 @@
   else:
     raise newException(Exception, "Unsupported audio file type: " & path)
 
+proc loadJson*(path: string, package = DEFAULT_PACKAGE): JsonNode =
+  path.loadResource_intern(package = package).readAll().parseJson()
+
 proc loadFont*(
   path: string,
   name = "",