Skip to content

Instantly share code, notes, and snippets.

@gmodarelli
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmodarelli/11179337 to your computer and use it in GitHub Desktop.
Save gmodarelli/11179337 to your computer and use it in GitHub Desktop.
XML2JSON
{
"root": {
"link": {
"_attributes": {
"href": "http://gmodarelli.com",
"rel": "self"
}
}
}
}
<root>
<link href="http://gmodarelli.com" rel="self" />
</root>
{
"root": {
"link": {
"_attributes": {
"href": "http://www.andreadippolito.it",
"rel": "self"
},
"_text": "wearemonk.com"
}
}
}
<root>
<link href="http://www.wearemonk.com" rel="self">wearemonk.com</link>
</root>
XML2JSON.config do |c|
c.attributes_key = "my_attributes"
c.namespaces_key = "my_namespaces"
c.text_key = "my_text"
end
gem 'xml2json', git: 'git@github.com:monksoftware/xml2json.git'
{
"root": {
"_namespaces": {
"xmlns": "http://some.namespace.definition"
},
"link": {
"_attributes": {
"href": "http://www.andreadippolito.it",
"rel": "self"
}
}
}
}
<root xmlns:"http://some.namespace.definition">
<link href="http://www.andreadippolito.it" rel="self" />
</root>
{
"root": {
"authors": [
{
"name": "Giuseppe Modarelli"
},
{
"name": "Andrea D'Ippolito"
}
]
}
}
<root>
<author>
<name>Giuseppe Modarelli</name>
</author>
<author>
<name>Andrea D'Ippolito</name>
</author>
</root>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment