/// <summary> /// Synchronize data is called by the javascript preparser to get an ready to use JSON parsed data. If the dat can't be parsed as JSON /// it will be returned as an common string /// </summary> /// <param name="uri">The address to the remote information to retrieve</param> /// <returns></returns> public object synchronize_data(string uri) { // Create web request WebClient WC = new WebClient(); /** * Try getting data. If no data was got an all, return FALSE * */ try { String jsonRaw = WC.DownloadString(new Uri(uri)); // Convert it to JSON try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(jsonRaw); return(xmlDoc); } catch { return(jsonRaw); } #if (obsolote) try { Jint.JintEngine Engine = new JintEngine(); Jint.Native.JsObject D = new Jint.Native.JsObject((object)jsonRaw); // Try parse it as json, otherwise try as xml and if not retuurn it as an string try { // Do not allow CLR when reading external scripts for security measurements System.Web.Script.Serialization.JavaScriptSerializer d = new System.Web.Script.Serialization.JavaScriptSerializer(); object json = d.DeserializeObject(jsonRaw); return(json); } catch { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(jsonRaw); return(xmlDoc); } } catch { return(jsonRaw); } #endif } catch { return(false); } }
/// <summary> /// Synchronize data is called by the javascript preparser to get an ready to use JSON parsed data. If the dat can't be parsed as JSON /// it will be returned as an common string /// </summary> /// <param name="uri">The address to the remote information to retrieve</param> /// <returns></returns> public object synchronize_data(string uri) { // Create web request WebClient WC = new WebClient(); /** * Try getting data. If no data was got an all, return FALSE * */ try { String jsonRaw = WC.DownloadString(new Uri(uri)); // Convert it to JSON try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(jsonRaw); return xmlDoc; } catch { return jsonRaw; } #if(obsolote) try { Jint.JintEngine Engine = new JintEngine(); Jint.Native.JsObject D = new Jint.Native.JsObject((object)jsonRaw); // Try parse it as json, otherwise try as xml and if not retuurn it as an string try { // Do not allow CLR when reading external scripts for security measurements System.Web.Script.Serialization.JavaScriptSerializer d = new System.Web.Script.Serialization.JavaScriptSerializer(); object json = d.DeserializeObject(jsonRaw); return json; } catch { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(jsonRaw); return xmlDoc; } } catch { return jsonRaw; } #endif } catch { return false; } }