Esempio n. 1
0
 public static ArrayList FromJsonArray(string str)
 {
     if (str == "")
         return new ArrayList();
     JSONArray root = new JSONArray(str);
     return FromJson(root);
 }
Esempio n. 2
0
        // [{"id":0,"name":"Davidson_County","parentLayerId":-1,"defaultVisibility":true,"subLayerIds":null}],"spatialReference":{"wkid":102113},"singleFusedMapCache":true,"tileInfo":{"rows":256,"cols":256,"dpi":96,"format":"JPEG","compressionQuality":75,"origin":{"x":-20037508.342787,"y":20037508.342787},"spatialReference":{"wkid":102113},"lods":[{"level":0,"resolution":156543.033928,"scale":591657527.591555},{"level":1,"resolution":78271.5169639999,"scale":295828763.795777},{"level":2,"resolution":39135.7584820001,"scale":147914381.897889},{"level":3,"resolution":19567.8792409999,"scale":73957190.948944},{"level":4,"resolution":9783.93962049996,"scale":36978595.474472},{"level":5,"resolution":4891.96981024998,"scale":18489297.737236},{"level":6,"resolution":2445.98490512499,"scale":9244648.868618},{"level":7,"resolution":1222.99245256249,"scale":4622324.434309},{"level":8,"resolution":611.49622628138,"scale":2311162.217155},{"level":9,"resolution":305.748113140558,"scale":1155581.108577},{"level":10,"resolution":152.874056570411,"scale":577790.554289},{"level":11,"resolution":76.4370282850732,"scale":288895.277144},{"level":12,"resolution":38.2185141425366,"scale":144447.638572},{"level":13,"resolution":19.1092570712683,"scale":72223.819286},{"level":14,"resolution":9.55462853563415,"scale":36111.909643},{"level":15,"resolution":4.77731426794937,"scale":18055.954822},{"level":16,"resolution":2.38865713397468,"scale":9027.977411},{"level":17,"resolution":1.19432856685505,"scale":4513.988705},{"level":18,"resolution":0.597164283559817,"scale":2256.994353},{"level":19,"resolution":0.298582141647617,"scale":1128.497176}]},"initialExtent":{"xmin":-9718317.13891344,"ymin":4282403.91976706,"xmax":-9605030.75071575,"ymax":4369195.91072496,"spatialReference":{"wkid":102113}},"fullExtent":{"xmin":-20037507.2295943,"ymin":-19971868.8804086,"xmax":20037507.2295943,"ymax":19971868.8804086,"spatialReference":{"wkid":102113}},"units":"esriMeters","supportedImageFormatTypes":"PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,AI","documentInfo":{"Title":"DavidsonFlood","Author":"agsglobe","Comments":"","Subject":"","Category":"","Keywords":""}}
        internal static List<GISLayerInfo> Create(JSONArray s)
        {
            List<GISLayerInfo> layers = new List<GISLayerInfo>();

            GISLayerInfo layer;

            foreach (JSONObject obj in s.List)
            {
                layer = EsriLayerInfo.Create(obj);
                if (layer != null) layers.Add(layer);
            }

            return layers;
        }
Esempio n. 3
0
        //internal static GISField ProcessFieldNode(FIELD field)
        //{
        //    GISField efield = new GISField();
        //    efield._fieldName = field.name;
        //    if (field.typeSpecified) efield._fieldValue = field.type.ToString();
        //    efield._size = field.size;
        //    efield._precision = field.precision;
        //    return efield;
        //}
        internal static void ProcessFields(List<GISField> fieldList, JSONArray fields)
        {
            bool hasFields = fieldList.Count > 0;

            if (hasFields) return;

            // [    {"name" : "<fieldName1>", "type" : "<fieldType1>", "alias" : "<fieldAlias1>"},    {"name" : "<fieldName2>", "type" : "<fieldType2>", "alias" : "<fieldAlias2>"}]

            foreach (JSONObject obj in fields.List)
            {
                EsriField f = new EsriField("temp");

                foreach (DictionaryEntry field in obj.getDictionary())
                {
                    switch (field.Key.ToString())
                    {
                        case "name":
                            f._fieldName = field.Value.ToString();
                            break;
                        case "type":
                            f._type = field.Value.ToString();
                            break;
                    }
                }

                fieldList.Add(f);
            }
        }
Esempio n. 4
0
        private static ArrayList FromJson(JSONArray vett)
        {
            ArrayList ret = new ArrayList();
            for (int i = 0; i < vett.Count; i++) {
                if (vett[i] is string) {
                    string sval = vett.getString(i);
                    ret.Add(sval);
                }
                else if (vett[i] is int) {
                    int ival = vett.getInt(i);
                    ret.Add(ival);
                }
                else if (vett[i] is JSONObject) {
                    JSONObject oval = vett.getJSONObject(i);
                    ret.Add(Map.FromJson(oval));
                }
                else if (vett[i] is JSONArray) {
                    JSONArray aval = vett.getJSONArray(i);
                    ret.Add(Map.FromJson(aval));
                }
            }

            return ret;
        }
Esempio n. 5
0
 /// <summary>
 /// Produce a JSONObject by combining a JSONArray of names with the values
 /// of this JSONArray.
 /// </summary>
 /// <param name="names">
 /// A JSONArray containing a list of key strings. These will be paired with the values.
 /// </param>
 /// <returns>A JSONObject, or null if there are no names or if this JSONArray</returns>
 public JSONObject toJSONObject(JSONArray names)
 {
     if (names == null || names.Length() == 0 || this.Length() == 0)
     {
         return null;
     }
     JSONObject jo = new JSONObject();
     for (int i=0; i <names.Length(); i++)
     {
         jo.put(names.getString(i),this.opt(i));
     }
     return jo;
 }
Esempio n. 6
0
        /// <summary>
        /// Append an array of JSONObjects to current object
        /// </summary>
        /// <param name="names"></param>
        /// <returns></returns>
        public JSONArray toJSONArray(JSONArray names)
        {
            if (names == null | names.Length() == 0)
                return null;

            JSONArray ja = new JSONArray();
            for (int i = 0; i < names.Length(); i++)
            {
                ja.put(this.opt(names.getString(i)));
            }
            return ja;
        }
Esempio n. 7
0
        /// <summary>
        /// Produce a JSONArray containing the names of the elements of this JSONObject
        /// </summary>
        /// <returns>A JSONArray containing the key strings, or null if the JSONObject</returns>
        public JSONArray names()
        {
            JSONArray ja = new JSONArray();

            //NOTE!! I choose to use keys stored in the ArrayList, to maintain sequence order
            foreach (string key in myKeyIndexList)
            {
                ja.put(key);
            }
            if (ja.Length() == 0)
            {
                return null;
            }
            return ja;
        }
Esempio n. 8
0
 /// <summary>
 /// Accumulate values under a key. It is similar to the put method except
 /// that if there is already an object stored under the key then a
 /// JSONArray is stored under the key to hold all of the accumulated values.
 /// If there is already a JSONArray, then the new value is appended to it.
 /// In contrast, the put method replaces the previous value.
 /// </summary>
 /// <param name="key">A key string.</param>
 /// <param name="val">An object to be accumulated under the key.</param>
 /// <returns>this</returns>
 public JSONObject accumulate(string key, object val)
 {
     JSONArray a;
     object obj = opt(key);
     if (obj == null)
     {
         put(key, val);
     }
     else if (obj is JSONArray)
     {
         a = (JSONArray)obj;
         a.put(val);
     }
     else
     {
         a = new JSONArray();
         a.put(obj);
         a.put(val);
         put(key, a);
     }
     return this;
 }