Comments (3)
Hm, I was thinking about json2xml replacing such characters with \"
or "e
but on second thought you might be right that user should pass a valid json in the first place. Thanks for answering!
from json2xml.
Thanks for reporting the issue. I will look into it and try to implement a fix for it.
from json2xml.
@SaraFarron I think I know what's going wrong. I am confirm that nothing goes wrong if you JSON is a valid string.
def test_dict_attr_crash(self):
data = data = {
"product": {
"@attrs": {
"attr_name": "attr_value",
"a": "b"
},
"@val": [],
},
}
result = json2xml.Json2xml(data).to_xml()
dict_from_xml = xmltodict.parse(result)
assert dict_from_xml["all"]["product"]["@attr_name"] == "attr_value"
assert dict_from_xml["all"]["product"]["@a"] == "b"
I added your JSON into a test and it just seems to work.
The issue with your JSON string is that you are adding the attrs in a '
quote.
{
"product": {
"@attrs": {
'attr_name': 'attr_value"'
},
"@val": [],
},
}
If you fix that, the data is like this:
{
"product": {
"@attrs": {
"attr_name": "attr_value"
},
"@val": [],
},
}
It would just work
from json2xml.
Related Issues (20)
- dicttoxml adds 'b...' HOT 4
- setting the xmlns value HOT 6
- setting xsi location HOT 3
- Logging should be disabled by default HOT 4
- Convert a dict with list to json without <list> elements HOT 1
- Wrap list items in their parent element HOT 1
- Ampersand not parsed correctly when attrs are present HOT 1
- List items as tags with arguments HOT 9
- Crash in one test when switching to pytest HOT 1
- dicttoxml: recursive array broken since json2xml 3.19.0 HOT 1
- some unit tests do not fail in test_dict2xml.py but should
- Security issues reported by dlint
- Lower requirements constraints HOT 6
- List items with attributes HOT 10
- Movie online database compatibility HOT 1
- validated json fails conversion HOT 4
- @attrs keyword does not work at the root level HOT 1
- Preserve certain text from being escaped HOT 2
- Deprecate setup.py and move to standard based tools
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json2xml.