Giter Site home page Giter Site logo

fastjson / android about fastjson HOT 8 CLOSED

alibaba avatar alibaba commented on May 3, 2024
fastjson / android

from fastjson.

Comments (8)

wenshao avatar wenshao commented on May 3, 2024

yes.

if your use code: https://github.com/AlibabaTech/fastjson/tree/1.1.22_android

------------------ 原始邮件 ------------------
发件人: "Timo Mika Gläßer"[email protected];
发送时间: 2012年10月25日(星期四) 凌晨2:22
收件人: "AlibabaTech/fastjson"[email protected];

主题: [fastjson] fastjson / android (#14)

can fastjson be made to work on android?

           —
           Reply to this email directly or view it on GitHub.

from fastjson.

zimdo avatar zimdo commented on May 3, 2024

sounds great... is there anything significant missing from that release? i think the last commit was a couple of months ago?

from fastjson.

wenshao avatar wenshao commented on May 3, 2024

for android, it's enough!

from fastjson.

wuyexiong avatar wuyexiong commented on May 3, 2024

太感谢了,膜拜。

from fastjson.

zimdo avatar zimdo commented on May 3, 2024

hey wenshao, i tried that... the library actually builds fine but the tests don't work... is that intended? or will i run into issues because it being buggy?

from fastjson.

zimdo avatar zimdo commented on May 3, 2024

Also just a note when I do something like this:

public class SplashActivity extends Activity {

    class Hello {

        public Hello() {

        }

        private String goodbye;

        public String getGoodbye() {
            return goodbye;
        }

        public void setGoodbye(String goodbye) {
            this.goodbye = goodbye;
        }


    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_splash);

        Log.d("TEST", "hello");
        Hello hello = JSON.parseObject("{goodbye: \"abc\"}", Hello.class);
        Log.d("TEST", hello.goodbye);
    }
}

it fails with the following stacktrace.

11-06 11:22:01.653: E/AndroidRuntime(18719): FATAL EXCEPTION: main
11-06 11:22:01.653: E/AndroidRuntime(18719): com.alibaba.fastjson.JSONException: create instance error, class com.affinityclick.hush.views.activities.SplashActivity$Hello
11-06 11:22:01.653: E/AndroidRuntime(18719): at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.createInstance(JavaBeanDeserializer.java:104)
11-06 11:22:01.653: E/AndroidRuntime(18719): at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:235)
11-06 11:22:01.653: E/AndroidRuntime(18719): at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:463)
11-06 11:22:01.653: E/AndroidRuntime(18719): at com.alibaba.fastjson.JSON.parseObject(JSON.java:206)
11-06 11:22:01.653: E/AndroidRuntime(18719): at com.alibaba.fastjson.JSON.parseObject(JSON.java:166)
11-06 11:22:01.653: E/AndroidRuntime(18719): at com.alibaba.fastjson.JSON.parseObject(JSON.java:287)
11-06 11:22:01.653: E/AndroidRuntime(18719): at com.affinityclick.hush.views.activities.SplashActivity$1.run(SplashActivity.java:57)
11-06 11:22:01.653: E/AndroidRuntime(18719): at android.os.Handler.handleCallback(Handler.java:615)
11-06 11:22:01.653: E/AndroidRuntime(18719): at android.os.Handler.dispatchMessage(Handler.java:92)
11-06 11:22:01.653: E/AndroidRuntime(18719): at android.os.Looper.loop(Looper.java:137)
11-06 11:22:01.653: E/AndroidRuntime(18719): at android.app.ActivityThread.main(ActivityThread.java:4745)
11-06 11:22:01.653: E/AndroidRuntime(18719): at java.lang.reflect.Method.invokeNative(Native Method)
11-06 11:22:01.653: E/AndroidRuntime(18719): at java.lang.reflect.Method.invoke(Method.java:511)
11-06 11:22:01.653: E/AndroidRuntime(18719): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-06 11:22:01.653: E/AndroidRuntime(18719): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-06 11:22:01.653: E/AndroidRuntime(18719): at dalvik.system.NativeStart.main(Native Method)
11-06 11:22:01.653: E/AndroidRuntime(18719): Caused by: java.lang.NullPointerException
11-06 11:22:01.653: E/AndroidRuntime(18719): at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.createInstance(JavaBeanDeserializer.java:101)
11-06 11:22:01.653: E/AndroidRuntime(18719): ... 15 more

When i make the inner-class "public static" it works again.

it also fails if i don't have an empty default constructor which is the way you show it your examples... but that's not a biggy.

from fastjson.

zimdo avatar zimdo commented on May 3, 2024

otherwise... pretty much everything seems to work.your library is awesome!

from fastjson.

wenshao avatar wenshao commented on May 3, 2024

public class SplashActivity extends Activity {

static class Hello { // none static inner class how create instance?
}

}

from fastjson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.