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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:09:42+00:00 2026-05-14T20:09:42+00:00

I am getting the following result from converting xml to JSON, using more than

  • 0

I am getting the following result from converting xml to JSON, using more than one conversion library. As you can see, the property name attributes are lost, as are the Item name attributes. Why?

Does anyone have recommendations on how I might change my XML to make it more conversion friendly?

<Asset name="xyz">
  <Property name="p1">Value 1</Property> 
  <Property name="p2">Value 2</Property> 
  <TimeSeries name="TimeSeries Name 1">
    <Item name="30 Apr 2009">97.47219</Item> 
    <Item name="01 May 2009">97.16496</Item> 
    <Item name="05 May 2009">97.34606</Item> 
  </TimeSeries>
</Asset>

Returns:

{
  "Asset": {
    "@attributes": {
      "name": "xyz"
    },
    "Property": ["Value 1", "Value 2"],
    "TimeSeries": {
      "@attributes": {
        "name": "TimeSeries Name 1"
      },
      "Item": ["97.47219", "97.16496", "97.34606"]
    }
  }
}

I have tried the following, but both the XML and JSON are a lot more verbose:

<Asset name="xyz">
  <Property><name>p1</name><value>Value 1</value></Property> 
  <Property><name>p2</name><value>Value 2</value></Property> 
  <TimeSeries name="TimeSeries Name 1">
      <Item><date>30 Apr 2009</date><value>97.47219</value></Item> 
      <Item><date>01 May 2009</date><value>97.16496</value></Item> 
      <Item><date>05 May 2009</date><value>97.34606</value></Item> 
  </TimeSeries>
</Asset>

resulting in…

{
  "Asset": {
    "@attributes": {
      "name": "xyz"
    },
    "Property": [{
      "name": "p1",
      "value": "Value 1"
    }, {
      "name": "p2",
      "value": "Value 2"
    }],
    "TimeSeries": {
      "@attributes": {
        "name": "TimeSeries Name 1"
      },
      "Item": [{
          "date": "30 Apr 2009",
          "value": "97.47219"
        },
        {
          "date": "01 May 2009",
          "value": "97.16496"
        }, {
          "date": "05 May 2009",
          "value": "97.34606"
        }
      ]
    }
  }
}
  • 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-14T20:09:42+00:00Added an answer on May 14, 2026 at 8:09 pm

    Probably you should never use attributes in the source XML file if you use this conversion tool.

    You main problem I see is that you don’t design the data yourself and try usage of a strange tool. If you use ASP.NET on the server side, it is much better to design your C# classes, initialize an instance of the classes with any test data and use JSON serialization like DataContractJsonSerializer or use a simple Web Service. Look at Can I return JSON from an .asmx Web Service if the ContentType is not JSON? or How do I build a JSON object to send to an AJAX WebService? as examples.

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

Sidebar

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.