Skip to content

Commit 860604b

Browse files
authored
Revert "Delete json funcs until Facepunch/garrysmod-issues#4976 is fixed (#2177)" (#2185)
This reverts commit c6ea454.
1 parent eb3841f commit 860604b

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

lua/entities/gmod_wire_expression2/core/serialization.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ local function jsonDecode( self, data, tp )
430430
end
431431

432432
__e2setcost(1)
433-
-- e2function string jsonError()
434-
-- return last_json_error or ""
435-
-- end
433+
e2function string jsonError()
434+
return last_json_error or ""
435+
end
436436

437437
__e2setcost(50)
438438

@@ -512,8 +512,8 @@ local function jsonEncode_start( self, data, prettyprint )
512512
end
513513

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

518518
-- this function converts a lua table into an E2 table
519519
local function jsonDecode_recurse( self, luatable, copied_tables )
@@ -552,10 +552,10 @@ local function jsonDecode_recurse( self, luatable, copied_tables )
552552
return e2table
553553
end
554554

555-
-- e2function table jsonDecode( string data )
556-
-- local luatable = jsonDecode( self, data, "external_t" )
557-
-- local copied_tables = {}
558-
-- return jsonDecode_recurse( self, luatable, copied_tables )
559-
-- end
555+
e2function table jsonDecode( string data )
556+
local luatable = jsonDecode( self, data, "external_t" )
557+
local copied_tables = {}
558+
return jsonDecode_recurse( self, luatable, copied_tables )
559+
end
560560

561561
__e2setcost(nil)

lua/wire/client/e2descriptions.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,10 +1456,16 @@ E2Helper.Descriptions["vonEncode(r)"] = "Encodes an array into a string using vO
14561456
E2Helper.Descriptions["vonEncode(t)"] = "Encodes a table into a string using vON"
14571457
E2Helper.Descriptions["vonError()"] = "Returns the last von error"
14581458

1459-
-- E2Helper.Descriptions["jsonDecode(s)"] = "Decodes a string into an array using json"
1460-
-- E2Helper.Descriptions["jsonEncode(t)"] = "Encodes a table into a string using json"
1461-
-- E2Helper.Descriptions["jsonEncode(tn)"] = "Encodes a table into a string using json"
1462-
-- E2Helper.Descriptions["jsonError()"] = "Returns the last json error"
1459+
E2Helper.Descriptions["jsonDecode(s)"] = "Decodes a string into an array using json"
1460+
E2Helper.Descriptions["jsonDecodeTable(s)"] = "Decodes a string into a table using json"
1461+
E2Helper.Descriptions["jsonEncode(r)"] = "Encodes an array into a string using json"
1462+
E2Helper.Descriptions["jsonEncode(rn)"] = "Encodes an array into a string using json"
1463+
E2Helper.Descriptions["jsonEncode(t)"] = "Encodes a table into a string using json"
1464+
E2Helper.Descriptions["jsonEncode(tn)"] = "Encodes a table into a string using json"
1465+
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."
1466+
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."
1467+
E2Helper.Descriptions["jsonDecodeTableExternal(s)"] = "Decodes a string into a table using json"
1468+
E2Helper.Descriptions["jsonError()"] = "Returns the last json error"
14631469

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

0 commit comments

Comments
 (0)