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 7511063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:26:07+00:00 2026-05-29T23:26:07+00:00

I have this XML structure that I wish to construct in JSON format using

  • 0

I have this XML structure that I wish to construct in JSON format using JavaScript – preferably using dot notation all the way if possible. ๐Ÿ™‚

Here is the XML – note this is a pseudo structure, to keep it simple! ๐Ÿ™‚

<Items>
   <Item>
      <Name>Item 1</Name>
      <SubItems>
         <Item>
           <Name>Sub Item 1</Name>
         </Item>
      </SubItems>
   </Item>
   <Item>
      <Name>Item 2</Name>
   </Item>
</Items>

So, when I convert my JSON to XML (on the server), the output should be like above.

I need help getting started with this. I Google’d around and I couldn’t find any examples on how to do this.

Thanks in advance!

EDIT: I am using NewtonSoft JSON for .NET to convert from JSON to XML!

EDIT 2: Ok, I figured out the Raw JSON structure to get the convertion to XML right – here it is:

var json = {
        "Items":
            {
                "Item":
                    [   
                        {
                            "Name": "Test 1" ,
                            "SubItems":
                            {
                                "Item":
                                    [
                                        {
                                            "Name":"Test 1"
                                        },
                                        {
                                            "Name":"Test 2"
                                        }
                                    ]
                            }
                        },
                        {
                            "Name":"Test 2"
                        }
                    ]
            }
    };

That will produce the exact same XML structure as defined above.

Now, how would I go about building this structure using dot notation?

EDIT 3: With the help of Nikhil & Darin, I figured it out, however this only answers the pseudo-question. However I will mark this as answered and create a new question. ๐Ÿ™‚

EDIT 4: I posted my extension to the marked answer. ๐Ÿ™‚

  • 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-05-29T23:26:09+00:00Added an answer on May 29, 2026 at 11:26 pm
    var json = {};
    json.Items = {};
    json.Items.Item = new Array();
    
    var item1 = {};
    item1.Name = "Test 1"
    item1.SubItems = new Array();
    
    var subItem1 = {};
    subItem1.Item = new Array();
    subSubItem1 = {};
    subSubItem1.Name = "Test 1";
    subSubItem2 = {};
    subSubItem2.Name = "Test 2";
    subItem1.Item.push(subSubItem1);
    subItem1.Item.push(subSubItem2);
    item1.SubItems.push(subItem1);
    var item2 = {};
    item2.Name = "Test 2";
    json.Items.Item.push(item1);
    json.Items.Item.push(item2);
    

    Output of the above code is

    {
        "Items": {
            "Item": [
                {
                    "Name": "Test 1",
                    "SubItems": [
                        {
                            "Item": [
                                {
                                    "Name": "Test 1"
                                },
                                {
                                    "Name": "Test 2"
                                }
                            ]
                        }
                    ]
                },
                {
                    "Name": "Test 2"
                }
            ]
        }
    }
    

    that should do it ๐Ÿ™‚

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a XML Structure that looks like this. <sales> <item name=Games sku=MIC28306200 iCat=28
I have a directory structure that looks like this: /a/f.xml /b/f.xml /c/f.xml /d/f.xml What
I have an XML structure that looks like this: <root> <index> <item>item 1</item> <item>item
I have a GWT application that created an XML structure and then posts this
I have an XML structure that looks like this: <?xml version=1.0?> <survey> <responses>0</responses> <question>
Im using CubeGallery3D, that stores with XML files. The XML structure looks like this:
I currently have an XML Structure that looks something like this <Parent> <Info> <Info-Data></Info-Data>
I have a piece of XML that is structured similar to this: <root> <score
I have xml structure like this: <Group id=2 name=Third parentid=0 /> <Group id=6 name=Five
So i have this XML structure: <fields> <field name=agent_description label=Agent Description size=area /> <field

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.