A novel approach is presented to solving the inverse diffractive grating problem in near-field optical imaging, which is to reconstruct perfectly conducting grating surfaces with resolution beyond the diffraction limit. The grating surface is assumed to be a small and smooth deformation of a plane surface. An analytical solution of the direct grating problems is derived by using the method of transformed field expansion. Based on the analytic solution, an explicit reconstruction formula is deduced for the inverse grating problem. The method requires only a single incident field and is realized...