Feedback

C# - JSON Parser

Veröffentlicht von am 8/4/2012
(0 Bewertungen)
Diese Klasse parsed euch alle Objekte aus JSON.

Die Objekte werden nicht serialized.
	/*
	Author: rvs14
	*/
         public String parsestrings(string wert1, string wert2)
        {
            String jobject = "\"" + wert1 + "\"" + ":" + "\"" + wert2 + "\"" + ",";
            return jobject.ToString();
        }
        public String parseboolean(string wert, bool booleran)
        {
            String boollittle = "false";
            if (booleran == true)
            {
                boollittle = "true";
            }
            
            String jobjectbool = "\"" + wert + "\"" + ":" + boollittle + ",";
            return jobjectbool.ToString();
        }
        public String parseinteger(string wert, int integer)
        {
            String jobjetint = "\"" + wert + "\"" + ":" + integer + ",";
            return jobjetint.ToString();
        }
        public String parsearray(String wert, String[] arr)
        {

            StringBuilder jobject = new StringBuilder();
            jobject.Append("\"");
            jobject.Append(wert);
            jobject.Append("\"");
            jobject.Append(":");
            jobject.Append("[");
            for (int i = 0; i < arr.Length; i++)
            {
                if (i != arr.Length - 1)
                {
                    jobject.Append(arr[i] + ",");

                }
                else
                {
                    jobject.Append(arr[i]);
                }
            }
            jobject.Append("],");
            return jobject.ToString();
        }
        public String parseobject(string wert, String[] objects)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("\"");
            builder.Append(wert);
            builder.Append("\"");
            builder.Append(":");
            builder.Append("{");
            for (int i = 0; i < objects.Length; i++)
            {
                if (i != objects.Length - 1)
                {
                    builder.Append("\"" + objects[i] + "\"" + ",");
                }
                else
                {
                    builder.Append("\"" + objects[i] + "\"");
                }

            }
            builder.Append("},");
            return builder.ToString();
        }
Abgelegt unter json, parser, parsen, objekte.

Kommentare zum Snippet

 

Logge dich ein, um hier zu kommentieren!