Created
February 20, 2009 08:26
-
-
Save atifaziz/67375 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
"xs:complexType", | |
{ | |
"name": "MyRequest" | |
}, | |
[ | |
"xs:annotation", | |
[ | |
"xs:documentation", | |
"\r\n This is the sample message\r\n" | |
] | |
], | |
[ | |
"xs:sequence", | |
[ | |
"xs:element", | |
{ | |
"minOccurs": "1", | |
"name": "requestEnvelope", | |
"type": "common:RequestEnvelope" | |
} | |
], | |
[ | |
"xs:element", | |
{ | |
"minOccurs": "1", | |
"maxOccurs": "1", | |
"name": "email", | |
"type": "xs:string" | |
} | |
], | |
[ | |
"xs:element", | |
{ | |
"minOccurs": "0", | |
"maxOccurs": "1", | |
"name": "transactionId", | |
"type": "xs:string" | |
} | |
], | |
[ | |
"xs:element", | |
{ | |
"minOccurs": "0", | |
"maxOccurs": "1", | |
"name": "trackingId", | |
"type": "xs:string" | |
} | |
], | |
[ | |
"xs:any", | |
{ | |
"maxOccurs": "unbounded", | |
"minOccurs": "0", | |
"namespace": "##other", | |
"processContents": "lax" | |
} | |
] | |
] | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Xml; | |
using Jayrock.Json; | |
using Jayrock.JsonML; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
const string @xml = @" | |
<xs:complexType name='MyRequest'> | |
<xs:annotation> | |
<xs:documentation> | |
This is the sample message | |
</xs:documentation> | |
</xs:annotation> | |
<xs:sequence> | |
<xs:element minOccurs='1' name='requestEnvelope' | |
type='common:RequestEnvelope' /> | |
<xs:element minOccurs='1' maxOccurs='1' | |
name='email' type='xs:string' /> | |
<xs:element minOccurs='0' maxOccurs='1' name='transactionId' type='xs:string'/> | |
<xs:element minOccurs='0' maxOccurs='1' name='trackingId' type='xs:string'/> | |
<xs:any maxOccurs='unbounded' minOccurs='0' | |
namespace='##other' processContents='lax' /> | |
</xs:sequence> | |
</xs:complexType>"; | |
StringWriter jsonw = new StringWriter(); | |
XmlTextReader reader = new XmlTextReader(new StringReader(xml)); | |
reader.Namespaces = false; | |
JsonMLCodec.Encode(reader, new JsonTextWriter(jsonw)); | |
Console.WriteLine(jsonw); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment