Skip to content

Conversation

@erikeldridge
Copy link
Contributor

@erikeldridge erikeldridge commented Mar 22, 2024

Discussion

As discussed with the API council, this change parses JSON string values into objects for convenience.

Given an interface:

interface GameConfig {
  user_level: number;
};

Instead of this:

let gameConfig: GameConfig = {};
try {
  gameConfig = JSON.parse(config.game_config_json as string);
} catch (e) { ... }

if (gameConfig.user_level > 10) { ... }

We can do this:

const gameConfig = config.game_config_json as unknown as GameConfig;

if (gameConfig.user_level > 10) { ... }

Testing

Ran npm test and all tests pass.

Functionally tested using a local server.

API Changes

Add JSONObject to RC API.

@erikeldridge erikeldridge changed the title Parse SSRC JSON strings into objects WIP: Parse SSRC JSON strings into objects Mar 22, 2024
@erikeldridge
Copy link
Contributor Author

Obviated by #2519

@erikeldridge erikeldridge deleted the ssrc-object branch April 2, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant