Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008172opensim[REGION] Script Functionspublic2017-05-20 11:412017-06-11 04:32
ReporterLotek 
Assigned ToLotek 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Platformx86_64OSLinuxOS VersionUbuntu 16.04LTS
Product Versionmaster (dev code) 
Target VersionFixed in Versionmaster (dev code) 
Summary0008172: llJsonGetValue on complex json results in empty list
DescriptionAfter I recompiled the OsCollar Camera app which is using json functions, I have found an issue with llJsonGetValue.

So i simplified the code in a test case and also went to the sandbox plaza on OsGrid which is running an older opensim version; there it worked correct. I think the bug was introduced with commit ef358051767546d1ae991112c80135041222018a
Steps To ReproduceJust past this in a box:

----------------------------------------------------------------------------

string g_sJsonModes;

list lJsonModes(string sMode) {
    string sJsonTmp = llJsonGetValue(g_sJsonModes, [sMode]);
    list lTest = llJson2List(sJsonTmp);
    integer index = llGetListLength(lTest)-1;
    //last entry is checked if it is a vector to be converted from string to vector here:
    if ((vector)llList2String(lTest,index)) lTest = llListReplaceList(lTest,[(vector)llList2String(lTest,index)],index,index);
    return lTest;
}

default
{
    state_entry()
    {
    string sDefault = llList2Json(JSON_ARRAY, [CAMERA_ACTIVE,FALSE]);
    string sHuman = llList2Json(JSON_ARRAY,[CAMERA_ACTIVE,TRUE,
                                                CAMERA_BEHINDNESS_ANGLE,0.0,
                                                CAMERA_BEHINDNESS_LAG,0.0,
                                                CAMERA_DISTANCE,2.5,
                                                CAMERA_FOCUS_LAG,0.05,
                                                CAMERA_POSITION_LOCKED,FALSE,
                                                CAMERA_FOCUS_THRESHOLD,0.0,
                                                CAMERA_PITCH,20.0,
                                                CAMERA_POSITION_LAG,0.0,
                                                CAMERA_POSITION_THRESHOLD,0.0,
                                                CAMERA_FOCUS_OFFSET,<0.0, 0.0, 0.35>]);
    string s1stperson = llList2Json(JSON_ARRAY,[CAMERA_ACTIVE,TRUE,
                                                CAMERA_DISTANCE, 0.5,
                                                CAMERA_FOCUS_OFFSET, <2.5,0,1.0>]);
    string sAss = llList2Json(JSON_ARRAY,[CAMERA_ACTIVE,TRUE,
                                                CAMERA_DISTANCE,0.5]);
    string sFar = llList2Json(JSON_ARRAY,[CAMERA_ACTIVE,TRUE,
                                                CAMERA_DISTANCE,10.0]);
    string sGod = llList2Json(JSON_ARRAY,[CAMERA_ACTIVE,TRUE,
                                                CAMERA_DISTANCE,10.0,
                                                CAMERA_PITCH,80.0]);
    string sGround = llList2Json(JSON_ARRAY,[CAMERA_ACTIVE,TRUE,
                                                CAMERA_PITCH,-15.0]);
    string sWorm = llList2Json(JSON_ARRAY,[CAMERA_ACTIVE,TRUE,
                                                CAMERA_PITCH,-15.0,
                                                CAMERA_FOCUS_OFFSET, <0.0,0.0,-0.75>]);

    g_sJsonModes = llList2Json(JSON_OBJECT,["default",sDefault,"human", sHuman, "1stperson",s1stperson,"ass",sAss,"far",sFar,"god",sGod,"ground",sGround,"worm",sWorm]);

    // Our data:
    llOwnerSay(g_sJsonModes+"\n\n");
    
    // Here is the fault:
    llOwnerSay(llJsonGetValue(g_sJsonModes, ["human"])+"\n\n");
 
    // function as used in OsCollar:
    llOwnerSay(llList2CSV(lJsonModes("human"))+"\n\n");
 
    }
}

----------------------------------------------------------------------------

Expected output:
Current simulator: OpenSim 0.9.1.0 Dev 8bdd4c3: 2017-05-12 12:30:59 +0100 (Unix/Mono)

[11:36] json test: {"default":"[12,false]","human":"[12,true,8,0.0,9,0.0,7,2.5,6,0.05,21,false,11,0.0,false,20.0,5,0.0,10,0.0,true,\"<0.000000, 0.000000, 0.350000>\"]","1stperson":"[12,true,7,0.5,true,\"<2.500000, 0.000000, 1.000000>\"]","ass":"[12,true,7,0.5]","far":"[12,true,7,10.0]","god":"[12,true,7,10.0,false,80.0]","ground":"[12,true,false,-15.0]","worm":"[12,true,false,-15.0,true,\"<0.000000, 0.000000, -0.750000>\"]"}


[11:36] json test: [12,true,8,0.0,9,0.0,7,2.5,6,0.05,21,false,11,0.0,false,20.0,5,0.0,10,0.0,true,"<0.000000, 0.000000, 0.350000>"]


[11:36] json test: 12, 1, 8, 0.000000, 9, 0.000000, 7, 2.500000, 6, 0.050000, 21, 0, 11, 0.000000, 0, 20.000000, 5, 0.000000, 10, 0.000000, 1, <0.000000, 0.000000, 0.350000>

----------------------------------------------------------------------------

Erroneous output on master:

[11:36] json test: {"default":[12,0],"human":[12,1,8,0.000000,9,0.000000,7,2.500000,6,0.050000,21,0,11,0.000000,0,20.000000,5,0.000000,10,0.000000,1,<0.000000, 0.000000, 0.350000>],"1stperson":[12,1,7,0.500000,1,<2.500000, 0.000000, 1.000000>],"ass":[12,1,7,0.500000],"far":[12,1,7,10.000000],"god":[12,1,7,10.000000,0,80.000000],"ground":[12,1,0,-15.000000],"worm":[12,1,0,-15.000000,1,<0.000000, 0.000000, -0.750000>]}


[11:36] json test: ?


[11:36] json test: ?

TagsNo tags attached.
Git Revision or version number9397b358d36067824b2cd4328398bbce9aecaa63
Run Mode Grid (1 Region per Sim)
Physics EngineubODE
EnvironmentMono / Linux64
Mono VersionOther
ViewerFirestorm
Attached Files

- Relationships
related to 0007984patch includedBlueWall llList2Json 

-  Notes
(0031884)
Lotek (reporter)
2017-05-20 11:55

Seems like the error is caused by llList2Json not enclosing the JSON_ARRAYs (converted to strings) in quotation marks ""
(0031885)
UbitUmarov (administrator)
2017-05-20 11:56

yes seems its the vectors and rotations handling.. looking into it
(0031886)
UbitUmarov (administrator)
2017-05-20 13:32

ok, should be better on master now
fear there maybe more issues.. pls let us know
(0031887)
Lotek (reporter)
2017-05-21 04:28

Hiya, yeah still throws an error because the arrays don't have "

See expected vs error:

[11:36] json test: {"default":"[12,false]"
Here the value for "default" is "[12,false]"

Now your code:
[04:19] json test: {"default":[12,0],

In the new code the value for "default" is [12,false] and not "[12,false]"
Notice the " missing around the array, it's invalid json.

Also the boolean false becomes now 0, but I'm not sure yet if that will cause a problem or is invalid.
(0031889)
UbitUmarov (administrator)
2017-05-21 08:21

On my region your test script above is giving the same results it does at SL

[08:07] mantis8172: {"default":[12,0],"human":[12,1,8,0.000000,9,0.000000,7,2.500000,6,0.050000,21,0,11,0.000000,0,20.000000,5,0.000000,10,0.000000,1,"<0.000000, 0.000000, 0.350000>"],"1stperson":[12,1,7,0.500000,1,"<2.500000, 0.000000, 1.000000>"],"ass":[12,1,7,0.500000],"far":[12,1,7,10.000000],"god":[12,1,7,10.000000,0,80.000000],"ground":[12,1,0,-15.000000],"worm":[12,1,0,-15.000000,1,"<0.000000, 0.000000, -0.750000>"]}

[08:02] SLObject: {"default":[12,0],"human":[12,1,8,0.000000,9,0.000000,7,2.500000,6,0.050000,21,0,11,0.000000,0,20.000000,5,0.000000,10,0.000000,1,"<0.000000, 0.000000, 0.350000>"],"1stperson":[12,1,7,0.500000,1,"<2.500000, 0.000000, 1.000000>"],"ass":[12,1,7,0.500000],"far":[12,1,7,10.000000],"god":[12,1,7,10.000000,0,80.000000],"ground":[12,1,0,-15.000000],"worm":[12,1,0,-15.000000,1,"<0.000000, 0.000000, -0.750000>"]}

[08:07] mantis8172: 12, 1, 8, 0.000000, 9, 0.000000, 7, 2.500000, 6, 0.050000, 21, 0, 11, 0.000000, 0, 20.000000, 5, 0.000000, 10, 0.000000, 1, <0.000000, 0.000000, 0.350000>

[08:02] SLObject: 12, 1, 8, 0.000000, 9, 0.000000, 7, 2.500000, 6, 0.050000, 21, 0, 11, 0.000000, 0, 20.000000, 5, 0.000000, 10, 0.000000, 1, <0.000000, 0.000000, 0.350000>

some cases floats show different number of right side zeros, but they are meaningless and that should not be a issue

in sDefault = llList2Json(JSON_ARRAY, [CAMERA_ACTIVE,FALSE]); and similar expressions FALSE and TRUE are encoded as integer 0 and 1.
to make them JSON Boolean types you need to use "true" (so "true" as string can't be used) or JSON_TRUE
see SL wiki.
(0031890)
UbitUmarov (administrator)
2017-05-21 08:22

same applies to null, you need to use "null" or JSON_NULL
(0031894)
UbitUmarov (administrator)
2017-05-21 08:47

Cases I know that not encode as SL;

 - char '/' is not escaped (as "\/"), seems that now is optional and lib LitJSON we use does not do it, and SL does.

 - json = llJsonSetValue("[]",[JSON_APPEND], "\"test\""); returns ["\"test\""] and not ["test"]
(0031895)
UbitUmarov (administrator)
2017-05-21 09:16

quote: "In the new code the value for "default" is [12,false] and not "[12,false]"
 Notice the " missing around the array, it's invalid json."

no, both are valid JSON, one encoded as string, other as array (identical for object) and your code asks for a array
doing later:
llOwnerSay((string)llJsonGetValue(g_sJsonModes,["human",1])); does work fine
(0031896)
Lotek (reporter)
2017-05-21 09:28

The key names for the camera params (such as human) where corrupt and returned JSON_INVALID in the object (collar). Probably because of tackling with this bug earlier. I had to do a hard reset on the object scripts and now it loads good.

As for TRUE and FALSE, in this case they are for camera parameters CAMERA_ACTIVE so they needed to be stored as integers 0 or 1.
(0031897)
BlueWall (administrator)
2017-05-21 09:40

Ubit - have a look at the patch in the related. I have been using that little regex for some time to prevent the structure in the json from being quoted and it seems ok.

- Issue History
Date Modified Username Field Change
2017-05-20 11:41 Lotek New Issue
2017-05-20 11:55 Lotek Note Added: 0031884
2017-05-20 11:56 UbitUmarov Note Added: 0031885
2017-05-20 13:32 UbitUmarov Note Added: 0031886
2017-05-21 04:28 Lotek Note Added: 0031887
2017-05-21 06:10 BlueWall Relationship added related to 0007984
2017-05-21 08:21 UbitUmarov Note Added: 0031889
2017-05-21 08:22 UbitUmarov Note Added: 0031890
2017-05-21 08:47 UbitUmarov Note Added: 0031894
2017-05-21 09:16 UbitUmarov Note Added: 0031895
2017-05-21 09:28 Lotek Note Added: 0031896
2017-05-21 09:32 Lotek Resolution open => fixed
2017-05-21 09:32 Lotek Fixed in Version => master (dev code)
2017-05-21 09:40 BlueWall Note Added: 0031897
2017-06-11 04:32 Lotek Status new => resolved
2017-06-11 04:32 Lotek Assigned To => Lotek


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker