0

I am writing a small program that converts a generated XML (using the C# XmlSerializer) to a Json. The converting from XML to Json is done via Json.NET. I have not used Json at all and I am not sure that the generated code is correct. What I am concerned about is that all the properties of the exported objects have a '@' prefix. Is that normal for a Json code? For example converting this XML:

<Icon Name="name1" Path="public/images/name1.png" Size="50x50">
  <IconCategories>
    <string>misc</string>
  </IconCategories>
</Icon>

is converted to:

{ 
  "Icon": 
  {
    "@Name": "name1",
    "@Path": "public/images/name1.png",
    "@Size": "50x50",
    "IconCategories": 
    { 
      "string": "misc"
    }
  }
}

Is the '@Name' normal or should it be 'Name'? Using this online xml to json convert also yields similar results but with instead of the '@' symbol the '-' is used.

2
  • Read the doc: newtonsoft.com/json/help/html/ConvertingJSONandXML.htm @ prefix is for attributes Commented Aug 24, 2015 at 12:45
  • Thank you, sorry for the duplicated question. I was searching for this question but didn't manage to find any solution. In the end I used the proposed Regex. Commented Aug 24, 2015 at 13:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.