ParseString() публичный Метод

Parses a JSON string and returns a book data struct from that
public ParseString ( string val ) : BookData,
val string
Результат BookData,
Пример #1
0
    /// <summary>
    /// Fetches the JSON data from a server
    /// </summary>
    private IEnumerator LoadJSONBookData(string jsonBookUrl)
    {
        // Gets the full book json url
        string fullBookURL = JsonServerUrl + jsonBookUrl;

        // Gets the json book info from the url
        mJsonBookInfo = new WWW(fullBookURL);
        yield return(mJsonBookInfo);

        // Loading done
        mIsLoadingBookData = false;

        if (mJsonBookInfo.error == null)
        {
            // Parses the json Object
            JSONParser parser = new JSONParser();

            BookData bookData = parser.ParseString(mJsonBookInfo.text);
            mBookData = bookData;

            // Updates the BookData info in the augmented object
            mBookInformationParser.UpdateBookData(bookData);

            mIsLoadingBookThumb = true;
        }
        else
        {
            Debug.LogError("Error downloading json");
        }
    }
Пример #2
0
    //functionforn video streaming

    private void LoadJSONBookData(string jsonBookUrl)
    {
        Debug.Log("inside json parsing ");
        // Gets the full book json url
        string fullBookURL = JsonServerUrl + jsonBookUrl;

        if (!mIsJSONRequested)
        {
            // Gets the json book info from the url
            mJsonBookInfo    = new WWW(fullBookURL);
            mIsJSONRequested = true;
            Debug.Log(fullBookURL);
        }

        //if(mJsonBookInfo.progress >= 1)
        //{
        if (mJsonBookInfo.error == null)
        {
            Debug.Log("json parsing started");
            // Parses the json Object
            JSONParser parser = new JSONParser();

            BookData bookData = parser.ParseString(mJsonBookInfo.text);
            //var str = parser.ParseString(mJsonBookInfo.text);
            //Debug.Log(str.v);
            mBookData = bookData;
            //Debug.Log(mBookData.BookTitle);

            // Updates state variables
            //mIsLoadingBookData = false;

            // Updates the BookData info in the augmented object
            mBookInformationParser.UpdateBookData(bookData);


            //mIsLoadingBookThumb = true;
        }
        else
        {
            Debug.LogError("Error downloading json");
            //mIsLoadingBookData = false;
        }
        //}
    }
Пример #3
0
    /// <summary>
    /// Fetches the JSON data from a local folder, called from TargetCreated()
    /// </summary>
    private IEnumerator LoadLocalJSONBookData(string filename)
    {
        LocalJasonFile = ConvertLocalJSONToString(filename);

        //mIsLoadingBookThumb = true;
        yield return(LocalJasonFile);

        // Loading done
        mIsLoadingBookData = false;

        // Parses the json Object
        JSONParser parser = new JSONParser();

        // Parses book data from JSON and assigns it to mBookData
        BookData bookData = parser.ParseString(LocalJasonFile);

        mBookData = bookData;
        Debug.Log(bookData);

        // Updates the BookData info in the augmented object
        mBookInformationParser.UpdateBookData(bookData);

        mIsLoadingBookThumb = true;
    }
Пример #4
0
    /// <summary>
    /// fetches the JSON data from a server
    /// </summary>
    private IEnumerator LoadJSONBookData(string jsonBookUrl)
    {
        // Gets the full book json url
        string fullBookURL = JsonServerUrl + jsonBookUrl;

        // Gets the json book info from the url
        mJsonBookInfo = new WWW(fullBookURL);
        yield return mJsonBookInfo;

        // Loading done
        mIsLoadingBookData = false;

        if (mJsonBookInfo.error == null)
        {
            // Parses the json Object
            JSONParser parser = new JSONParser();

            BookData bookData = parser.ParseString(mJsonBookInfo.text);
            mBookData = bookData;

            // Updates the BookData info in the augmented object
            mBookInformationParser.UpdateBookData(bookData);

            mIsLoadingBookThumb = true;
        }
        else
        {
            //Debug.LogError("Error downloading json");
            BookData bookData = new BookData();
            bookData.SetBookTitle("The Hunger Game");
            bookData.SetBookAuthor("Suzanne Collins");
            bookData.SetBookRating(4);
            bookData.SetBookOverallRating(23933);
            bookData.SetBookRegularPrice(10.99f);
            bookData.SetBookYourPrice(7.09f);
            bookData.SetBookThumbUrl("http://ecx.images-amazon.com/images/I/41bOj-am1RL._SX331_BO1,204,203,200_.jpg");
            bookData.SetBookDetailUrl("http://www.amazon.com/The-Hunger-Games-Book-1/dp/0439023521/ref=pd_bxgy_14_img_z");

            mBookData = bookData;
            Debug.Log("mBookData assigned");

            // Updates the BookData info in the augmented object
            mBookInformationParser.UpdateBookData(bookData);

            mIsLoadingBookThumb = true;
        }
    }
    //functionforn video streaming
    private void LoadJSONBookData(string jsonBookUrl)
    {
        Debug.Log("inside json parsing ");
        // Gets the full book json url
        string fullBookURL = JsonServerUrl + jsonBookUrl;

        if(!mIsJSONRequested){

            // Gets the json book info from the url
            mJsonBookInfo = new WWW(fullBookURL);
            mIsJSONRequested = true;
            Debug.Log(fullBookURL);

        }

        //if(mJsonBookInfo.progress >= 1)
        //{
            if(mJsonBookInfo.error == null )
            {
                Debug.Log("json parsing started");
                // Parses the json Object
                JSONParser parser = new JSONParser();

                BookData bookData = parser.ParseString(mJsonBookInfo.text);
                //var str = parser.ParseString(mJsonBookInfo.text);
                //Debug.Log(str.v);
                mBookData = bookData;
                //Debug.Log(mBookData.BookTitle);

                // Updates state variables
                //mIsLoadingBookData = false;

                // Updates the BookData info in the augmented object
                mBookInformationParser.UpdateBookData(bookData);

                //mIsLoadingBookThumb = true;

            }else
            {
                Debug.LogError("Error downloading json");
                //mIsLoadingBookData = false;
            }
        //}
    }