There was no indication that the suspect, believed to be Chinese, intentionally targeted Japanese nationals, the official of the Japanese Consulate General in Shanghai told Kyodo news agency.
Also Read: Knife attack in Chinese hospital leaves 10 killed or injured
The injuries suffered by the two Japanese nationals were not life-threatening.
The attacker was subdued at the scene.
Also Read: China: Knife attack at a primary school in Jiangxi leaves 2 persons dead
The attacker is currently in police custody.
Also Read: China: Six die in knife attack in Lianjiang
The motive behind the attack is not known so far.
Earlier this month, four instructors from an American college were stabbed by a Chinese man in Jilin city.
The suspect in the Jilin attack was arrested by the police but the motive behind the incident is still not known.