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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:52:20+00:00 2026-05-23T01:52:20+00:00

I am aware of several open source java libraries that will convert XML to

  • 0

I am aware of several open source java libraries that will convert XML to JSON.

However, I am looking for a library (or way) that will suppress the leading @ that is prepended to the element attribute. So, for example, given the JSON string below:

{ "description":
      { "@lang":"en-us",
        "@maxlength":"500",
        "#text":"Vitamin D Supplementation"
      }
}

I would like to produce the following JSON string (notice the missing @ in front of “lang” and “maxlength”):

{ "description":
      { "lang":"en-us",
        "maxlength":"500",
        "#text":"Vitamin D Supplementation"
      }
}

As far as I can tell, no libraries offer a way to do this. Maybe there is a way to accomplish this using Regex, though I would have to be careful of not stripping valid @ characters in data?

  • 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-23T01:52:21+00:00Added an answer on May 23, 2026 at 1:52 am

    String.replace("\"@", "\"") or what?

    UPDATE

    To prevent replacing the @ within a string value, you could use the regexp version of replace. You’d look for the @ sign preceded by ” and not preceded by some X, where X is a colon (:) followed by any number of whitespace. You’d replace by the ” again.

    A less hacky approach would be to have a library stream the json in a content-event-like fashion, catch any object member name events, replace such member names that begin with an @ accordingly and then throw them back to the event stream. That stream would then be converted to JSON text again. (I’m currently working on a library that provides such functionality, but it’s not yet published, unfortunately.)

    Similarly, you could hook in the XML to JSON translation process. The translator would have to stream the XML to some sort of XML content events, which are later converted to JSON content events, which are then stringified to JSON text. (Ok, that’s how I would do it.) If you could plug in at either side of the JSON events stage, you could easily translate specific object member names. Obviously the library you use would have to make plugging in possible, if only by offering the steps of the process for separate invocation.

    (In case you wondered, “object member name” is the part before the : in a JSON object, the “value” is the part after it.)

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

Sidebar

Related Questions

I've seen several questions regarding problems with generating classes from XML Schema using xsd.exe
I am building a JSON-RPC server that accepts requests over HTTP. I would like
I'm adding tags to several models (Posts, Articles, Photos, etc). I'm aware of rails
I unfortunately have several macros left over from the original version of my library
A broad question. We have a client application that currently talks to a web
Some background info: We have several websites running on a 64-bit machine with IIS6
We have a several large MFC applications which presently call a COM object to
I'm trying to use a SqlDataReader (I'm quite aware of the beauty of Linq,
I'm working on reformatting HTML output from a search query for an inventory manager
We are currently developing an application based on NHibernate and ASP.NET MVC and 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.