public static AVObject parseAVObject ( String objectString ) { if ( StringUtil . isEmpty ( objectString ) ) { return null ; } // replace leading type name to compatible with v4.x android sdk serialized json string. objectString = objectString . replaceAll ( "^\\{\\s*\"@type\":\\s*\"[A-Za-z\\.]+\"," , "{" ) ; // objectString = objectString.replaceAll("^\\{\\s*\"@type\":\\s*\"cn.leancloud.AV(Object|Installation|User|Status|Role|File)\",", "{"); // replace old AVObject type name. objectString = objectString . replaceAll ( "\"@type\":\\s*\"com.avos.avoscloud.AVObject\"," , "\"@type\":\"cn.leancloud.AVObject\"," ) ; objectString = objectString . replaceAll ( "\"@type\":\\s*\"com.avos.avoscloud.AVInstallation\"," , "\"@type\":\"cn.leancloud.AVInstallation\"," ) ; objectString = objectString . replaceAll ( "\"@type\":\\s*\"com.avos.avoscloud.AVUser\"," , "\"@type\":\"cn.leancloud.AVUser\"," ) ; objectString = objectString . replaceAll ( "\"@type\":\\s*\"com.avos.avoscloud.AVStatus\"," , "\"@type\":\"cn.leancloud.AVStatus\"," ) ; objectString = objectString . replaceAll ( "\"@type\":\\s*\"com.avos.avoscloud.AVRole\"," , "\"@type\":\"cn.leancloud.AVRole\"," ) ; objectString = objectString . replaceAll ( "\"@type\":\\s*\"com.avos.avoscloud.AVFile\"," , "\"@type\":\"cn.leancloud.AVFile\"," ) ; objectString = objectString . replaceAll ( "\"@type\":\\s*\"com.avos.avoscloud.ops.[A-Za-z]+Op\"," , "" ) ; return JSON . parseObject ( objectString , AVObject . class , Feature . SupportAutoType ) ; }
create AVObject instance from json string which generated by AVObject . toString or AVObject . toJSONString .