diff --git a/data/dev/sl-lua-defs.json b/data/dev/sl-lua-defs.json index 0ff169d..f6c82ad 100644 --- a/data/dev/sl-lua-defs.json +++ b/data/dev/sl-lua-defs.json @@ -5,10 +5,7 @@ "name": "numeric", "definition": { "kind": "union", - "types": [ - "boolean", - "number" - ] + "types": ["boolean", "number"] } }, { @@ -39,24 +36,21 @@ "name": "DetectedEventName", "definition": { "kind": "literal-union", - "values": [ ] + "values": [] } }, { "name": "NonDetectedEventName", "definition": { "kind": "literal-union", - "values": [ ] + "values": [] } }, { "name": "EventName", "definition": { "kind": "union", - "types": [ - "DetectedEventName", - "NonDetectedEventName" - ] + "types": ["DetectedEventName", "NonDetectedEventName"] } }, { @@ -574,7 +568,7 @@ "type": "boolean" } ], - "methods": [ ] + "methods": [] } ], "globalVariables": [ @@ -611,10 +605,7 @@ ], "returnType": { "kind": "union", - "types": [ - "quaternion", - "nil" - ] + "types": ["quaternion", "nil"] }, "comment": "Creates a quaternion from a string argument in format `<1,1,1,1>` Invalid strings will return `nil` #### Caveat Due to an old error from lsl strings that match upto the closing `>` are interpreted as valid So `<1,1,1,1` and `<1,1,1,1spoon` are both cast to `<1,1,1,1>` When testing if a string is a quaternion or a vector, you should test with `toquaternion` first." }, @@ -628,10 +619,7 @@ ], "returnType": { "kind": "union", - "types": [ - "vector", - "nil" - ] + "types": ["vector", "nil"] }, "comment": "Creates a vector from a string argument in format `<1,1,1>` Invalid strings will return `nil` #### Caveat Due to an old error from lsl strings that match upto the closing `>` are interpreted as valid So `<1,1,1`, `<1,1,1,1` and `<1,1,1spoon` are all cast to `<1,1,1>` When testing if a string is a quaternion or a vector, you should test with `toquaternion` first." }, @@ -962,6 +950,62 @@ ], "returnType": "string", "comment": "encode lua value as json" + }, + { + "comment": "decode json string to lua value preserving types", + "name": "sldecode", + "parameters": [ + { + "name": "json", + "type": "string" + } + ], + "returnType": { + "kind": "union", + "types": [ + "string", + "number", + "vector", + "uuid", + "quaternion", + "boolean", + { + "elementType": "", + "kind": "array" + }, + "nil" + ] + } + }, + { + "comment": "encode lua value as json preserving types. use tight to encode more compactly", + "name": "slencode", + "parameters": [ + { + "name": "value", + "type": { + "kind": "union", + "types": [ + "string", + "number", + "vector", + "uuid", + "quaternion", + "boolean", + { + "elementType": "", + "kind": "array" + }, + "nil" + ] + } + }, + { + "name": "tight", + "type": "boolean" + } + ], + "returnType": "string" } ] }, @@ -1016,10 +1060,7 @@ "name": "value", "type": { "kind": "union", - "types": [ - "string", - "buffer" - ] + "types": ["string", "buffer"] } } ], diff --git a/data/syntax_def_default.json b/data/syntax_def_default.json index ca21e5f..dc45736 100644 --- a/data/syntax_def_default.json +++ b/data/syntax_def_default.json @@ -15428,10 +15428,7 @@ ], "returnType": { "kind": "union", - "types": [ - "quaternion", - "nil" - ] + "types": ["quaternion", "nil"] } }, { @@ -15445,10 +15442,7 @@ ], "returnType": { "kind": "union", - "types": [ - "vector", - "nil" - ] + "types": ["vector", "nil"] } }, { @@ -15808,6 +15802,62 @@ } ], "returnType": "string" + }, + { + "comment": "decode json string to lua value preserving types", + "name": "sldecode", + "parameters": [ + { + "name": "json", + "type": "string" + } + ], + "returnType": { + "kind": "union", + "types": [ + "string", + "number", + "vector", + "uuid", + "quaternion", + "boolean", + { + "elementType": "", + "kind": "array" + }, + "nil" + ] + } + }, + { + "comment": "encode lua value as json preserving types. use tight to encode more compactly", + "name": "slencode", + "parameters": [ + { + "name": "value", + "type": { + "kind": "union", + "types": [ + "string", + "number", + "vector", + "uuid", + "quaternion", + "boolean", + { + "elementType": "", + "kind": "array" + }, + "nil" + ] + } + }, + { + "name": "tight", + "type": "boolean" + } + ], + "returnType": "string" } ], "name": "lljson", @@ -15901,10 +15951,7 @@ "name": "value", "type": { "kind": "union", - "types": [ - "string", - "buffer" - ] + "types": ["string", "buffer"] } } ], @@ -16110,20 +16157,14 @@ { "definition": { "kind": "union", - "types": [ - "boolean", - "number" - ] + "types": ["boolean", "number"] }, "name": "numeric" }, { "definition": { "kind": "union", - "types": [ - "string", - "uuid" - ] + "types": ["string", "uuid"] }, "name": "uuid_like" }, @@ -16168,10 +16209,7 @@ { "definition": { "kind": "union", - "types": [ - "DetectedEventName", - "NonDetectedEventName" - ] + "types": ["DetectedEventName", "NonDetectedEventName"] }, "name": "EventName" },