Json::Value FileSaver::StoreSkeleton(const SkeletonData& skeleton) { Json::Value value; const std::map<ee::SprPtr, std::vector<Joint*> >& map_joints = skeleton.GetMapJoints(); std::map<ee::SprPtr, std::vector<Joint*> >::const_iterator itr = map_joints.begin(); for (int i = 0; itr != map_joints.end(); ++itr, ++i) { value[i]["sprite"] = itr->first->GetName(); for (int j = 0, m = itr->second.size(); j < m; ++j) { Joint* joint = itr->second[j]; Json::Value joint_val; joint_val["id"] = joint->GetID(); joint_val["rx"] = joint->GetCurrRelativePos().x; joint_val["ry"] = joint->GetCurrRelativePos().y; if (const Joint* parent = joint->GetParent()) { joint_val["parent"] = parent->GetID(); } const std::set<Joint*>& children = joint->GetChildren(); std::set<Joint*>::const_iterator itr_child = children.begin(); for (int k = 0; itr_child != children.end(); ++itr_child, ++k) { joint_val["children"][k] = (*itr_child)->GetID(); } value[i]["joints"][j] = joint_val; } } return value; }