Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lua/entities/gmod_wire_expression2/core/serialization.lua
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ local function jsonDecode( self, data, tp )
end

__e2setcost(1)
-- e2function string jsonError()
-- return last_json_error or ""
-- end
e2function string jsonError()
return last_json_error or ""
end

__e2setcost(50)

Expand Down Expand Up @@ -512,8 +512,8 @@ local function jsonEncode_start( self, data, prettyprint )
end

-- Used to encode an E2 table to a Lua table, so that it can be used by external resources properly.
-- e2function string jsonEncode( table data ) return jsonEncode_start( self, data, 0 ) end
-- e2function string jsonEncode( table data, prettyprint ) return jsonEncode_start( self, data, prettyprint ) end
e2function string jsonEncode( table data ) return jsonEncode_start( self, data, 0 ) end
e2function string jsonEncode( table data, prettyprint ) return jsonEncode_start( self, data, prettyprint ) end

-- this function converts a lua table into an E2 table
local function jsonDecode_recurse( self, luatable, copied_tables )
Expand Down Expand Up @@ -552,10 +552,10 @@ local function jsonDecode_recurse( self, luatable, copied_tables )
return e2table
end

-- e2function table jsonDecode( string data )
-- local luatable = jsonDecode( self, data, "external_t" )
-- local copied_tables = {}
-- return jsonDecode_recurse( self, luatable, copied_tables )
-- end
e2function table jsonDecode( string data )
local luatable = jsonDecode( self, data, "external_t" )
local copied_tables = {}
return jsonDecode_recurse( self, luatable, copied_tables )
end

__e2setcost(nil)
14 changes: 10 additions & 4 deletions lua/wire/client/e2descriptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1456,10 +1456,16 @@ E2Helper.Descriptions["vonEncode(r)"] = "Encodes an array into a string using vO
E2Helper.Descriptions["vonEncode(t)"] = "Encodes a table into a string using vON"
E2Helper.Descriptions["vonError()"] = "Returns the last von error"

-- E2Helper.Descriptions["jsonDecode(s)"] = "Decodes a string into an array using json"
-- E2Helper.Descriptions["jsonEncode(t)"] = "Encodes a table into a string using json"
-- E2Helper.Descriptions["jsonEncode(tn)"] = "Encodes a table into a string using json"
-- E2Helper.Descriptions["jsonError()"] = "Returns the last json error"
E2Helper.Descriptions["jsonDecode(s)"] = "Decodes a string into an array using json"
E2Helper.Descriptions["jsonDecodeTable(s)"] = "Decodes a string into a table using json"
E2Helper.Descriptions["jsonEncode(r)"] = "Encodes an array into a string using json"
E2Helper.Descriptions["jsonEncode(rn)"] = "Encodes an array into a string using json"
E2Helper.Descriptions["jsonEncode(t)"] = "Encodes a table into a string using json"
E2Helper.Descriptions["jsonEncode(tn)"] = "Encodes a table into a string using json"
E2Helper.Descriptions["jsonEncodeExternal(t)"] = "Encodes a table into a string using json, in a form that is suitable to be exported to external resources. Unfortunately, arrays are ignored because E2 contains many ambiguous types, and arrays don't keep track of those types. You will have to convert your array to a table manually before encoding it."
E2Helper.Descriptions["jsonEncodeExternal(tn)"] = "Encodes a table into a string using json, in a form that is suitable to be exported to external resources. Unfortunately, arrays are ignored because E2 contains many ambiguous types, and arrays don't keep track of those types. You will have to convert your array to a table manually before encoding it."
E2Helper.Descriptions["jsonDecodeTableExternal(s)"] = "Decodes a string into a table using json"
E2Helper.Descriptions["jsonError()"] = "Returns the last json error"

-- http
E2Helper.Descriptions["httpCanRequest()"] = "Returns whether you can make a new request (delay has been met or previous request timed out)"
Expand Down