Skip to content
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

feat(spells): do json manipulations internally #1433

Merged
merged 3 commits into from
Jan 30, 2023
Merged

feat(spells): do json manipulations internally #1433

merged 3 commits into from
Jan 30, 2023

Conversation

justprosh
Copy link
Member

  • spell's getDataSrv returns parsed json value, so there is no need to parse it manually
  • spell.install now accepts any object as init_data (previously, it was accepting only stringified ones)
  • spell's response accepts objects (previously, it was accepting only stringified ones)

@justprosh justprosh requested a review from folex January 26, 2023 17:24
@@ -66,7 +66,7 @@ pub(crate) async fn spell_install(
services.call_function(
&spell_id,
"set_json_fields",
vec![json!(init_data)],
vec![json!(init_data.to_string())],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be enough to pass init_data.to_string()? If not, why not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call_function accepts function_args: Vec<JValue>

process_func_outcome::<UnitValue>(
services.call_function(
spell_id,
"set_json_fields",
args.function_args.clone(),
vec![json!(response.to_string())],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing, why do you serialize it to json twice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_json_fields accepts string that can be parsed to json

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response.to_string() seems to satisfy that description

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but call_function accepts function_args: Vec<JValue>

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.

None yet

2 participants