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

  • Home
  • SEARCH
  • 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 7975503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:39:32+00:00 2026-06-04T08:39:32+00:00

I need to pass some parameters to server that i need to pass as

  • 0

I need to pass some parameters to server that i need to pass as below
format

{
  "k2": {
    "mk1": "mv1",
    "mk2": [
      "lv1",
      "lv2"
    ]
  }
}

So how can generate this format in android.

I tried this using the As shown in example 5.3 but it is showing a error at obj.writeJSONString(out); this line. Can anyone please help in solving this.

Thanks In Advance

  • 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-04T08:39:33+00:00Added an answer on June 4, 2026 at 8:39 am

    Its not that though at all, output you want is JSONArray inside JSONObject and JSONObject inside another JSONObject. So, you can create them seperately and then can put in together. as below.

    try {
                JSONObject parent = new JSONObject();
                JSONObject jsonObject = new JSONObject();
                JSONArray jsonArray = new JSONArray();
                jsonArray.put("lv1");
                jsonArray.put("lv2");
    
                jsonObject.put("mk1", "mv1");
                jsonObject.put("mk2", jsonArray);
                parent.put("k2", jsonObject);
                Log.d("output", parent.toString(2));
            } catch (JSONException e) {
                e.printStackTrace();
            }
    

    Output-

           {
               "k2": {
                 "mk1": "mv1",
                 "mk2": [
                   "lv1",
                   "lv2"
                 ]
               }
             }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to pass '+' via the QueryString . some special character can be
I am doing a multi-threaded application in C# and need to pass some parameters
I have a stored procedure on my server that inserts some parameters and returns
So I have a situation where I need to pass some parameters on url.
I have a Backbone Collection and I need to pass some parameters to the
im trying to pass some parameters from my a4j:mediaOutput to my bean. I can
I'm writing a web application where I need to pass some user data to
I need to find a way to pass some strings to my word 2003
I am writing some and I need to pass a complicated data structure to
I am writing some kind of IPC functionality and need to pass certain resources

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.