Those are the same in meaning. Indeed it can be said that the former one is used in a situation where comparing what was done (e.g. かれはすいえいをしました。そしてわたしはにほんごのべんきょうをしました。 He did swimming, and I did learning of Japanese.), and the latter is for a situation where comparing what was studied (e.g. かのじょはすうがくをべんきょうしました。そしてわたしはにほんごをべんきょうしました。 She learned math, and I learned Japanese.), but there is no problem to use にほんごをべんきょうしました in the former situation, and vise versa.
The point you need to pay more attention is not the difference in meaning but the difference in the choice of the particle. As you can see, を is also used in the latter sentence. べんきょう is a noun in べんきょうをしました, so you need to use の after にほんご (learning of Japanese), but べんきょうする is a transitive verb "to learn", so を is used for the object にほんご (to learn Japanese). The same goes to へやのそうじをしました "I did cleaning of my room" vs. へやをそうじしました "I cleaned my room".