Reasons for doing it:
Magic- The Magic are dead last in offense, and tied for last in 3p makes per game. Cam Johnson helps with that, and they aren't giving up anything that makes their team worse right now, Cole Anthony is not a valuable player for them anymore.
Nets- The Nets are simply too good for their own good. They need to lose a lot more games, and trading Cam Johnson will do that. They get back Cole Anthony and Caleb Houstan, who might be solid players some day, along with some draft capital.