kyamagu / matlab-json

Use official API: https://mathworks.com/help/matlab/json-format.html
Other
52 stars 15 forks source link

Command didn't produce json file #5

Open zakimohzani opened 8 years ago

zakimohzani commented 8 years ago

Hello, Great job, mister. Unfortunately, the following line doesn't work in my R2013b.

json.write({'a',NaN,'c'},'test.json')

Could you explain why?

kyamagu commented 8 years ago

Did you compile the java code first?

kyamagu commented 8 years ago

It could be that Java version is not compatible with the provided jar files in java directory. If that's the case, you have to compile java package using the provided Makefile.

zakimohzani commented 8 years ago

Not sure what compiling does. How do I compile java code in matlab? I've tried the command with {'a','b'} and it works. I'm using the json provided from your website 0.2.2. Am 23.03.2016 11:39 Vorm. schrieb "Kota Yamaguchi" <notifications@github.com

:

Did you compile the java code first?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/kyamagu/matlab-json/issues/5#issuecomment-200151967

kyamagu commented 8 years ago

Ok, then download the latest version from Github. v0.2.2 does not support inf/nan values.

zakimohzani commented 8 years ago

Sorry to bother you, here's another roadblock for me. Am I add supposed to add the org folder to the path?

>> json.test.run
=== json.test.dump ===
Undefined variable "org" or class "org.json.JSONObject.NULL".

Error in json.dump>dumpData (line 80)
    obj = org.json.JSONObject.NULL;

Error in json.dump (line 67)
  obj = dumpData(value, options);

Error in json.test.dump (line 29)
    str = json.dump(fixtures{i,1});

Error in json.test.run (line 11)
    tests{i}();
zakimohzani commented 8 years ago

Alright, so then I tried to compile it by running your Makefile but also failed, I guess it can't find the other files. I'm using cygwin now to make it.

MOZ1SGP@SGPL3803117 /cygdrive/c/Users/MOZ1SGP/Desktop/Model/framework/lib/matlab-json/java
$ make
javac -cp .:junit-4.12.jar:hamcrest-core-1.3.jar org/json/Cookie.java
org\json\Cookie.java:81: error: cannot find symbol
    public static JSONObject toJSONObject(String string) throws JSONException {
                  ^
  symbol:   class JSONObject
  location: class Cookie
org\json\Cookie.java:81: error: cannot find symbol
    public static JSONObject toJSONObject(String string) throws JSONException {
                                                                ^
  symbol:   class JSONException
  location: class Cookie
org\json\Cookie.java:118: error: cannot find symbol
    public static String toString(JSONObject jo) throws JSONException {
                                  ^
  symbol:   class JSONObject
  location: class Cookie
org\json\Cookie.java:118: error: cannot find symbol
    public static String toString(JSONObject jo) throws JSONException {
                                                        ^
  symbol:   class JSONException
  location: class Cookie
org\json\Cookie.java:83: error: cannot find symbol
        JSONObject     jo = new JSONObject();
        ^
  symbol:   class JSONObject
  location: class Cookie
org\json\Cookie.java:83: error: cannot find symbol
        JSONObject     jo = new JSONObject();
                                ^
  symbol:   class JSONObject
  location: class Cookie
org\json\Cookie.java:85: error: cannot find symbol
        JSONTokener x = new JSONTokener(string);
        ^
  symbol:   class JSONTokener
  location: class Cookie
org\json\Cookie.java:85: error: cannot find symbol
        JSONTokener x = new JSONTokener(string);
                            ^
  symbol:   class JSONTokener
  location: class Cookie
org\json\Cookie.java:158: error: cannot find symbol
                int d = JSONTokener.dehexchar(string.charAt(i + 1));
                        ^
  symbol:   variable JSONTokener
  location: class Cookie
org\json\Cookie.java:159: error: cannot find symbol
                int e = JSONTokener.dehexchar(string.charAt(i + 2));
                        ^
  symbol:   variable JSONTokener
  location: class Cookie
10 errors
Makefile:14: recipe for target 'org/json/Cookie.class' failed
make: *** [org/json/Cookie.class] Error 1
kyamagu commented 8 years ago

Hmm, looks very much like a Java version issue. What does ver command say about Java VM version? I'll investigate.

zakimohzani commented 8 years ago

Alright, so I took the binaries from Maven and used their jar and now it runs.

K>> json.test.run
=== json.test.dump ===
PASS: fixture 1
PASS: fixture 2
PASS: fixture 3
PASS: fixture 4
PASS: fixture 5
PASS: fixture 6
PASS: fixture 7
PASS: fixture 8
PASS: fixture 9
PASS: fixture 10
PASS: fixture 11
PASS: fixture 12
PASS: fixture 13
PASS: fixture 14
PASS: fixture 15
PASS: fixture 16
PASS: fixture 17
PASS: fixture 18
PASS: fixture 19
PASS: fixture 20
PASS: fixture 21
=== json.test.load ===
PASS: fixture 1
PASS: fixture 2
FAIL: fixture 3: 'Infinity'.
FAIL: fixture 4: '-Infinity'.
FAIL: fixture 5: 'NaN'.
PASS: fixture 6
PASS: fixture 7
PASS: fixture 8
PASS: fixture 9
PASS: fixture 10
PASS: fixture 11
PASS: fixture 12
PASS: fixture 13
PASS: fixture 14
PASS: fixture 15
PASS: fixture 16
PASS: fixture 17

By the way,

K>> ver
----------------------------------------------------------------------------------------------------
MATLAB Version: 8.2.0.701 (R2013b)
MATLAB License Number: 1073034
Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)
Java Version: Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MATLAB                                                Version 8.2        (R2013b)
Simulink                                              Version 8.2        (R2013b)
Control System Toolbox                                Version 9.6        (R2013b)
GUI Layout Toolbox                                    Version 1.17       (R2013b)
PLECS Piece-wise Linear Electrical Circuit Simu...    Version 3.7.1              
K>> 
kyamagu commented 8 years ago

Alright, probably the Maven version doesn't support Inf/nan values but other conversions will work.

zakimohzani commented 8 years ago

You're right, it doesn't. So what should I do now? Wait for you? Am 23.03.2016 3:27 Nachm. schrieb "Kota Yamaguchi" <notifications@github.com

:

Alright, probably the Maven version doesn't support Inf/nan values but other conversions will work.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/kyamagu/matlab-json/issues/5#issuecomment-200227520

kyamagu commented 8 years ago

I'll investigate, but meanwhile you can try to compile java codes by changing the classpath in javac.

kyamagu commented 8 years ago

@zakimohzani If you haven't fixed this issue, checkout the latest commit. The minimum requirement for Java is now ver 1.6.0_65.

zakimohzani commented 8 years ago

Sorry Yamaguchi-san for the late reply and I do appreciate your efforts. Further apologies for the fact that I can only test it later as I will be flying out for work soon. Do remind me once in awhile as I am very forgetful. (Too many issue trackers to follow, I need an aggregator for the issue trackers :P)