Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9097903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:13:57+00:00 2026-06-17T00:13:57+00:00

I have this JSON string that I am recieving after I make a purchase

  • 0

I have this JSON string that I am recieving after I make a purchase from the playstore and I am apparently missing something in my code when I am trying to parse it.

PurchaseInfo:{"orderId":"12999763165555505758.1317333586444405",
    "packageName":"com.mypkgname.myapp",
    "productId":"monthly_purchase_01",
    "purchaseTime":1357456489000,
    "purchaseState":0,
    "purchaseToken":"yrynypfkdncvhlxdbypysvwz.AO-J1OxFkndfqkClAqbbYAOApkMgTG4VX9Ef0uNP0FIs9-xGrXivkbx3FNMA2yNU12K_sbvRGFcknVBTfisI-uZawCXLGlMX4v4Zw8GFOmS0Q6PIbiITTGqn5h1QbEB4Rv84sXdUJHP3B_UQfujZN7ADi9bm_N4_iA"}

Here is the snippet of code I am using it to attempt the parsing

       try {

            JSONObject j1 = new JSONObject(tester1);             
                JSONArray mPurchInfo = j1.getJSONArray("PurchaseInfo");          

                int count = mPurchInfo.length();

                final String[] purchInfo = new String[count];
            JSONObject q1 = mPurchInfo.getJSONObject(0);

            purchInfo[0] = q1.getString("orderId");
                    purchInfo[1] = q1.getString("packageName");
                purchInfo[2] = q1.getString("productId");
                purchInfo[3] = q1.getString("purchaseTime");
                purchInfo[4] = q1.getString("purchaseState");
            purchInfo[5] = q1.getString("purchaseToken");
                orderID=purchInfo[0];

          } catch (JSONException e) {
                Log.e("Error","Yes");
          }

I am catching the an error as I see this last log statement in my log but I am still trying to learn the parsing JSON Strings

I hope I am at least close
Ideally I would like to have Strings set to all the values in the JSON String

orderID = ??
packageName = ??
etc.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:13:59+00:00Added an answer on June 17, 2026 at 12:13 am

    I have this JSON string that I am recieving after I make a purchase from the playstore

    If that’s really what you get back, you need to contact them and tell them to fix their API; that string is not valid JSON. There are two problems with it:

    1. A JSON document must have an object or array as the top-level item. The string as quoted is missing a { at the beginning and a } at the end.

    2. All keys in JSON must be in double quotes. The first one, PurchaseInfo, is not.

    Also, your code is doing this:

    JSONArray mPurchInfo = j1.getJSONArray("PurchaseInfo"); 
    

    …but if it were valid JSON, PurchaseInfo wouldn’t be an array, it’d be an object.

    Looking at it, if you remove the PurchaseInfo: at the beginning, it’s valid. Once you’ve removed that, this line:

    JSONObject j1 = new JSONObject(tester1);
    

    …will give you an object from which you can query information:

    String orderId = j1.getString("orderId");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSON string that looks like this: { package1: { type: envelope,
I have this json string: $row['medium'] = {\medium\:13|17|1|14, \medium_sub\:21}; now I want to make
I have this JSON response string: {d:{\ID_usuario\:\000130\,\Nombre\:null,\Vipxlo\:0,\Provmun\:null,\Descuentos\:null,\Listaviplocal\:null}}` With this code: - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
I am getting JSON string from website. I have data which looks like this
I have this JSon string received from an AJAX call: {status:OK,addresses:[0,1,2,3,4,5]} To convert it
Possible Duplicate: How to parse JSON in JavaScript I have this JSON string: [{title:
I have a YQL output JSON string at this URL: YQL JSON I found
I have a json string like this: { d: { results: [ { __metadata:
I have this JSON http://www.progmic.com/ielts/retrive.php that I need to parse. When I do it
I have the following C# helper class which retrieves a Json String from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.