mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 16:18:01 +01:00
Hotfix for Cryo (JSON problems) and render issues (Internet Explorer)
Blame MSO
This commit is contained in:
@@ -1,17 +1,8 @@
|
||||
#define LIST_FLAT 0
|
||||
#define LIST_NESTED 1
|
||||
#define LIST_OBJECT 2 //object in this case means json object, orther wise known as an associative list
|
||||
#define LIST_OBJECT 2 // Object in this case means json object, ortherwise known as an associative list or array.
|
||||
|
||||
json_writer/var/use_cache = 0
|
||||
json_writer/proc/WriteObject(list/L)
|
||||
if(use_cache && L["__json_cache"])
|
||||
return L["__json_cache"]
|
||||
. = list()
|
||||
for(var/k in L)
|
||||
. += "\"[k]\":[write(L[k])]"
|
||||
|
||||
. = "{[list2text(., ",")]}"
|
||||
|
||||
|
||||
json_writer/proc/write(val)
|
||||
if(isnum(val))
|
||||
@@ -25,10 +16,19 @@ json_writer/proc/write(val)
|
||||
if (LIST_NESTED)
|
||||
. = write_array(val)
|
||||
if (LIST_OBJECT)
|
||||
. = WriteObject(val)
|
||||
. = write_object(val)
|
||||
else
|
||||
. = write_string("[val]")
|
||||
|
||||
json_writer/proc/write_object(list/L)
|
||||
if(use_cache && L["__json_cache"])
|
||||
return L["__json_cache"]
|
||||
. = list()
|
||||
for(var/k in L)
|
||||
. += "\"[k]\":[write(L[k])]"
|
||||
|
||||
. = "{[list2text(., ",")]}"
|
||||
|
||||
json_writer/proc/write_flat_array(list/L)
|
||||
. = "\[[list2text(L, ",")]]"
|
||||
|
||||
@@ -53,15 +53,15 @@ json_writer/proc/write_string(txt)
|
||||
return {""[txt]""}
|
||||
|
||||
json_writer/proc/listtype(list/L)
|
||||
. = LIST_FLAT
|
||||
. = LIST_FLAT
|
||||
for(var/key in L)
|
||||
if (. == LIST_FLAT && istype(key, /list))
|
||||
. = LIST_NESTED
|
||||
if (!isnum(key) && !isnull(L[key]) && !istype(key, /list))
|
||||
if (!isnum(key) && !istype(key, /list))
|
||||
. = LIST_OBJECT
|
||||
break // if it's an object, we can just stop now
|
||||
|
||||
|
||||
break // If it's an object, we can just stop now.
|
||||
|
||||
|
||||
#undef LIST_FLAT
|
||||
#undef LIST_NESTED
|
||||
#undef LIST_OBJECT
|
||||
#undef LIST_OBJECT
|
||||
|
||||
Reference in New Issue
Block a user