View Issue Details

IDProjectCategoryView StatusLast Update
0000992GT-MP ClientAPIpublic2018-02-23 23:52
ReporterRuffoAssigned To 
Status newResolutionopen 
Product Version 
Target VersionFixed in Version 
Summary0000992: API.toJson(..)/API.fromJson(..) VS JSON.stringify(..)/JSON.parse(..) (Current CoolKids Beta)
Description(Current CoolKids Beta)
See the Javascript (client) code:
I'm confused that only one API function works, and the equivalent function works only in the JSON. variant.
Steps To Reproduceinterface AuthOpen {
  Type: 'Login' | 'Register',
  Username?: string

API.onServerEventTrigger.connect((eventName, args) => {
  if (eventName === 'AuthOpen') {
    const arg = JSON.parse(args[0]) as AuthOpen
    const arg2 = API.fromJson(args[0]) as AuthOpen

    API.sendChatMessage(`~c~1| ~b~API.toJson(arg) ~w~ ${API.toJson(arg)}`) // Works
    API.sendChatMessage(`~c~2| ~b~JSON.stringify(arg) ~w~ ${JSON.stringify(arg)}`) // Works
    API.sendChatMessage(`~c~3| ~b~API.toJson(arg2) ~w~ ${API.toJson(arg2)}`) // returns undefined!
    API.sendChatMessage(`~c~4| ~b~JSON.stringify(arg2) ~w~ ${JSON.stringify(arg2)}`) // Works
TagsAPI.toJson; API.fromJson


There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2018-02-23 23:52 Ruffo New Issue
2018-02-23 23:52 Ruffo Tag Attached: API.toJson; API.fromJson