added more intelligent implementation of serializing json data

Change-Id: Iead258a0c77e63af44f5af9d1728fe257c62b0d1