简体   繁体   中英

how can an object be not json serializable?

    private FbDataToServer generateFbDataToServer(
            GraphObject graphObject) {
            Gson gson = new Gson();
            FbDataToServer fbDataToServer = new FbDataToServer();
  ֿ         fbDataToServer.fbJson = gson.toJson(graphObject
            .getInnerJSONObject());

Everytime I try to parse FB graphObject object to Json -

an error is thrown.

How can it be? how can an object be not json serializable?

The error said the object is not serializable. I'll try to get reproduce the error again.

Actually, i have never use the facebook API. But when it comes to serialize the object to json string, i recommend you that fastjson is much better. https://github.com/alibaba/fastjson

Fastjson is the fastest processing library in java (even than jackson, let alone gson) and it has no special requirements to the object ,just be the pain java bean is enough.

By the way, fastjson is developed by Chinese, so its documentation are mainly in Chinese. If you have trouble with its api, you can contact with me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM