How to solve the problem of Json/xml interchange in C #

Source: Internet
Author: User
Tags json tojson

I've recently used JSON and XML to convert from one POC project to another, although I know that many libraries like json.net have this functionality, but I've been using spider Studio to quickly implement this feature with an online tool site.

Online Tools Website: Http://www.utilities-online.info/xmltojson

Prerequisites: Spider Studio (Acquisition workstation): http://www.gdtsearch.com/products.spiderstudio.htm

1. Open spider Studio, load page http://www.utilities-online.info/xmltojson/

2. Select the page element feature to find the XML and JSON two input boxes and two mutually convertible buttons, their IDs are: #json, #xml, #tojson, #toxml.

3. Scripting automatically completes page operations:

public void Run ()
{
    logger.clearall ();
    Logger.Log (Xml2json ("<person><name>Mike</name><age>30</age></person>"));
    Logger.Log (Json2xml ("{' person ': {' name ': ' Mike ', ' Age ':}}");
}
    
public string Xml2json (string xml)
{
    lock (this)
    {
        default.navigate ("http:// Www.utilities-online.info/xmltojson ");
        Default.ready ();
        Default.selectsinglenode ("#xml"). Text (XML);
        Default.selectsinglenode ("#tojson"). Click ();
        var json = Default.selectsinglenode ("#json"). Text ();
        return JSON;
    }
}
    
public string Json2xml (string json)
{
    lock (this)
    {
        default.navigate ("http:// Www.utilities-online.info/xmltojson ");
        Default.ready ();
        Default.selectsinglenode ("#json"). Text (JSON);
        Default.selectsinglenode ("#toxml"). Click ();
        var xml = Default.selectsinglenode ("#xml"). Text ();
        return XML;
    }
}

Test effect:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.