Recently, IoT has greatly influenced our daily lives through various applications. One of the most promising application is smart city that leverages IoT devices to manage cities without any human intervention. The high possibility of sensing and publishing sensitive data in this smart environment leads to three significant issues: (1) privacy-preserving (2) heterogeneity, and (3) real-time services. We observe that current studies are in lack of addressing these challenges. In this paper, we propose a new privacy-preserving architecture for IoT devices in the smart city by leveraging ontology, a data model, at the edge of the network. At first, we propose an ontology that consists of privacy information of devices. Then, we mount a real-time privacy-preserving method on top of it that is achieved by providing a dynamic environment from the privacy-preserving point of view. Based on the simulation results using Protege and Visual Studio on a synthetic dataset, we find that our solution provides privacy at real-time while addressing heterogeneity issue so that many IoT devices can afford it. Thus, our proposed solution can be widely used for smart cities.