-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Namespace prefixes stripped out from XML element keys and attributes #120
Comments
Can you provide example to review? |
Yeah, @clbanning
With this, I am getting error : And if I use |
I'm running the following version of your example and everything is behaving as expected. (go1.17 darwin/amd64) Please edit this to reproduce the errors you reference. `package main import (
) func main() {
} |
Ooops, Anyway thank you. |
No. Do you get the same errors as before with go1.21.3? If you do, then I'll upgrade to the tip and relook at the results - something may have changed in stdlib. (I've not keep up with go versions for several years, obviously.) |
Yes, I go the same errors with go1.21.3 |
Thanks. Give me a few days to look into this. |
Just ran program I sent in previous comment with go1.21.12 darwin/amd64, and it ran as expected without error. So I'm a bit mystified about why you'd be getting errors - it successfully runs with go1.17.3, go1.19.3, and go1.21.12. Please run the code I provided and upload all the output including fmt.Println output and error messages. |
Hey @clbanning , Apologies, for the delay in my response, here is the results of the code that I ran with the logs, you can check that, that Xml val from Map Val got failed, rest of 3 steps worked fine. Below are the complete results.
|
OK. I see a number of errors in the last encoding, though not what you have. First, by default mxj casts boolean-like values to boolean values which aren't getting re-encoded correctly after passing through the JSON encoding/decoding steps. (See, CastValuesToBool(...).) Also, the JSON value encodes the MapSeq meta-keys, "#seq" and "text", as JSON keys, so when it's unmarshaled to a Map they are also preserved as map keys. To have them handled you need to invoke the MapSeq XML encoder as 'xml, err := mxj.MapSeq(mv).XmlIndent("", " ")'. I'll need to find some time to trace through the CastValuesToBool(...) handling between decoders and encoders for Map and MapSeq as there is some inconsistency including the JSON decoding that uses stdlib. Don't know when that'll be right now. If you can email me a general outline of what you're trying to accomplish, I might be able to suggest a workaround. Otherwise I'll have to recommend you investigate some other XML decoder library. |
Hey @clbanning ,
x2j.XmlToJson() when using this, the prefixes are stripping out from the xml elements, in json.
Is there anyway to handle this,
I even looked to #110 , but that is even getting to fail by getting this error :
invalid attribute key label: #text - due to attributes not being prefixed
when converting back to xml from the generated json.The text was updated successfully, but these errors were encountered: