Skip to content

WIP: Parse SSRC JSON strings into objects #2504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

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