Skip to content

able to get inner content by utilizing GetJsonValueByPath - #115

Open
cielavenir wants to merge 2 commits into
masterfrom
improveResourceGet
Open

able to get inner content by utilizing GetJsonValueByPath#115
cielavenir wants to merge 2 commits into
masterfrom
improveResourceGet

Conversation

@cielavenir

Copy link
Copy Markdown
Contributor

these will be possible

double max_tool_speed_rot = object->Get<double>("robot_motion_parameters/max_tool_speed_rot");
string ikTypeName = object->Get<string>("robot_motion_parameters/ikTypeName");
map<string, vector<int>> params = object->Get<map<string, vector<int>>>("robot_motion_parameters/int_parameters");

note that we cannot do object->Get<map<string, map<string, vector<int>>>>("robot_motion_parameters");. This is C++ limitation.


We will use GetJsonValueByPath, so we add leading / to field variable (after copying to temporary variable).

@ziyan

ziyan commented Oct 18, 2022

Copy link
Copy Markdown
Member
  1. who is the user of this?
  2. so much small std::string copy and creation
if(path[0]!='/') {
path = std::string("/")+field;
}
std::string fieldToConstraint = path.substr(1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@cielavenir looks pretty inefficient with creating all these strings on the heap, especially when rapidjson doesn't require std::string

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

well, alternative ideas are:

  1. use GetJsonValueByPath only when field contains "/"
  2. add a new API named GetPath

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added GetPath now

@cielavenir

Copy link
Copy Markdown
Contributor Author
@cielavenir
cielavenir requested a review from lazydroid November 2, 2022 06:42
@cielavenir

Copy link
Copy Markdown
Contributor Author

btw I realized std::string fieldToConstraintForCallGet = path.substr(1, path.find('/', 1)); is better, please tell me such matter(s) /cc @lazydroid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants