aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
authorDr Scofield2008-09-29 17:47:17 +0000
committerDr Scofield2008-09-29 17:47:17 +0000
commit87ac46c1c5d7235aba8905e98f4819a3bf54c563 (patch)
tree53b3ef40f6d5a26834f15a9e2379a682bc0b7ce9 /OpenSim/Region/ScriptEngine/Shared/Api
parent* Fix http://opensimulator.org/mantis/view.php?id=2189 for real this time (diff)
downloadopensim-SC-87ac46c1c5d7235aba8905e98f4819a3bf54c563.zip
opensim-SC-87ac46c1c5d7235aba8905e98f4819a3bf54c563.tar.gz
opensim-SC-87ac46c1c5d7235aba8905e98f4819a3bf54c563.tar.bz2
opensim-SC-87ac46c1c5d7235aba8905e98f4819a3bf54c563.tar.xz
From: rob smart (smartrob@uk.ibm.com)
minor fixes to osParseJSON.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs28
1 files changed, 22 insertions, 6 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 536bdd2..cd17734 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -749,13 +749,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
749 string currentKey=null; 749 string currentKey=null;
750 Stack objectStack = new Stack(); // objects in JSON can be nested so we need to keep a track of this 750 Stack objectStack = new Stack(); // objects in JSON can be nested so we need to keep a track of this
751 Hashtable jsondata = new Hashtable(); // the hashtable to be returned 751 Hashtable jsondata = new Hashtable(); // the hashtable to be returned
752 752 int i=0;
753 try 753 try
754 { 754 {
755 755
756 // iterate through the serialised stream of tokens and store at the right depth in the hashtable 756 // iterate through the serialised stream of tokens and store at the right depth in the hashtable
757 // the top level hashtable may contain more nested hashtables within it each containing an objects representation 757 // the top level hashtable may contain more nested hashtables within it each containing an objects representation
758 for (int i=0;i<JSON.Length; i++) 758 for (i=0;i<JSON.Length; i++)
759 { 759 {
760 760
761 // Console.WriteLine(""+JSON[i]); 761 // Console.WriteLine(""+JSON[i]);
@@ -795,10 +795,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
795 string tokenValue=""; 795 string tokenValue="";
796 i++; // move to next char 796 i++; // move to next char
797 797
798 // just loop through until the next quote mark storing the string 798 // just loop through until the next quote mark storing the string, ignore quotes with pre-ceding \
799 while (JSON[i]!='"') 799 while (JSON[i]!='"')
800 { 800 {
801 tokenValue+=JSON[i++]; 801 tokenValue+=JSON[i];
802
803 // handle escaped double quotes \"
804 if(JSON[i]=='\\' && JSON[i+1]=='"')
805 {
806 tokenValue+=JSON[i+1];
807 i++;
808 }
809 i++;
810
802 } 811 }
803 812
804 // ok we've got a string, if we've got an array on the top of the stack then we store it 813 // ok we've got a string, if we've got an array on the top of the stack then we store it
@@ -857,6 +866,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
857 else 866 else
858 { 867 {
859 ((Hashtable)objectStack.Peek()).Add(currentKey,true); 868 ((Hashtable)objectStack.Peek()).Add(currentKey,true);
869 currentKey=null;
860 } 870 }
861 871
862 //advance the counter to the letter 'e' 872 //advance the counter to the letter 'e'
@@ -871,11 +881,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
871 else 881 else
872 { 882 {
873 ((Hashtable)objectStack.Peek()).Add(currentKey,false); 883 ((Hashtable)objectStack.Peek()).Add(currentKey,false);
884 currentKey=null;
874 } 885 }
875 //advance the counter to the letter 'e' 886 //advance the counter to the letter 'e'
876 i = i+4; 887 i = i+4;
877 break; 888 break;
878 889 case '\n':// carriage return
890 // just ignore
891 break;
892 case '\r':// carriage return
893 // just ignore
894 break;
879 default: 895 default:
880 // ok here we're catching all numeric types int,double,long we might want to spit these up mr accurately 896 // ok here we're catching all numeric types int,double,long we might want to spit these up mr accurately
881 // but for now we'll just do them as strings 897 // but for now we'll just do them as strings
@@ -909,7 +925,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
909 } 925 }
910 catch(Exception) 926 catch(Exception)
911 { 927 {
912 OSSLError("osParseJSON: The JSON string is not valid " + JSON); 928 OSSLError("osParseJSON: The JSON string is not valid " + JSON) ;
913 } 929 }
914 930
915 return jsondata; 931 return jsondata;