Wednesday, May 23, 2018

Data Mapper - Using Joins with Multiple Data Sources

This video shows you how to create a transform to join data from multiple data sources using Liquid Data Mapper.






A free trial of the Liquid Data Mapper is available from:
https://www.liquid-technologies.com/trial-download

Monday, May 14, 2018

JSON Data Binding with Liquid XML 2018 – Update 1

XML to JSON and JSON to XML the smart way


Liquid XML Data Binder has helped developers work with XML for nearly 20 years. In more recent times passing data between heterogeneous systems, specifically backend to mobile devices, has become increasingly reliant on using JSON data structures.

In order to facilitate this, we have introduced the FromJson and ToJson set of methods to the Liquid Runtime API which will serialize and deserialize JSON data to and from the generated data objects.

Supported languages are C++, C#, Visual Basic .Net and Java.

C# Example

    // create an instance of the class to load the XML file into
    Bookstore elm = new Bookstore();
                    
    // load the initial XML data from a file into the object
    elm.FromXmlFile(filename);

    // change the price of the first book to 10.99
    elm.BookCol[0].Price = 10.99;
    
    // extract the updated data into an XML string
    string strXml = elm.ToXml();
    Console.WriteLine($"The XML created\n{strXml}");
    
    // extract the updated data into a JSON string
    string strJson = elm.ToJson();
    Console.WriteLine($"The JSON created\n{strJson}");

C++ Example

    // create an instance of the class to load the XML file into
    CBookstorePtr spElm = CBookstore::CreateInstance();
    
    // load the initial XML data from a file into the object
    spElm ->FromXmlFile(lpctFilename);
    
    // change the price of the first book to 10.99
    spElm->GetBookCol()->Item(0)->SetPrice(10.99);

    // extract the updated data into an XML string
    std::tstring strXml = spElm ->ToXml();
    _tprintf(_T("The XML created\n%s"), strXml.c_str());
    
    // extract the updated data into a JSON string
    std::tstring strJson = spElm ->ToJson();
    _tprintf(_T("The JSON created\n%s"), strJson.c_str());

The XML created

    <bs:bookstore xmlns:bs="http://www.liquid-technologies.com/sample/bookstore">
                   xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
      <bs:book price="10.99" publicationdate="2008-10-20" ISBN="978-0747596837">
      <bs:title>The Graveyard Book</bs:title>
      <bs:author>
        <bs:first-name>Neil</bs:first-name>
        <bs:last-name>Gaiman</bs:last-name>
      </bs:author>
      <bs:genre>Horror</bs:genre>
      </bs:book>
... etc ...
    </bs:bookstore>

The JSON created

  {
    "bs:bookstore": {
      "@xmlns:bs": "http://www.liquid-technologies.com/sample/bookstore",
      "@xmlns:xs": "http://www.w3.org/2001/XMLSchema-instance",
      "bs:book": [
        {
          "@price": 10.99,
          "@publicationdate": "2008-10-20",
          "@ISBN": "978-0747596837",
          "bs:title": "The Graveyard Book",
          "bs:author": {
            "bs:first-name": "Neil",
            "bs:last-name": "Gaiman"
          },
          "bs:genre": "Horror"
        },
... etc ...
      ]
    }
  }

 

JSON to Object Roundtripping 

 

Looking at the JSON document, by default, attributes are prefixed with '@', namespace attributes are written out '@xmlns:bs' and names contain the namespace prefix 'bs:'. This is to enable full roundtripping of JSON back into the data objects using ToJson and FromJson methods.

If we want a vanilla JSON document, we can control the output using the SerializationContext.

 

C# Example

    SerializationContext.Default.JsonContext.SupportRoundtrip = JsonContext.RoundTrip.None;

C++ Example

    CSerializationContext::GetDefaultContext().GetJsonContext().SetSupportRoundtrip(JsonRoundTrip_None);

Now when the code is executed, the JSON output is as follows

  {
    "bookstore": {
      "book": [
        {
          "price": 10.99,
          "publicationdate": "2008-10-20",
          "ISBN": "978-0747596837",
          "title": "The Graveyard Book",
          "author": {
            "first-name": "Neil",
            "last-name": "Gaiman"
          },
          "genre": "Horror"
        },
... etc ...
      ]
    }
  }


Download a free trial of Liquid XML Data Binder today:
https://www.liquid-technologies.com/trial-download


Tuesday, May 08, 2018

Liquid Studio 2018 - Update 1

Liquid Studio 2018 - Update 1 (v16.1.0)

We are pleased to announce Update 1 of Liquid Studio 2018, adding new features and enhancements as requested by our end users.
  • NEW JSON support in XML Data Binder for C++, .Net and Java using ToJson() and FromJson() API methods.
  • Improved XML Data Binder Errors to include XPath or JSONPath to error location.
  • Fixed issue for BinaryData created with empty data in Liquid C++ Runtime.
  • Database Views can now be used as data sources.
  • Data Mapper Database Reader and Database Writer components can now use the app.Config to get the connection string.
  • Data Mapper Join now retains connectors when changing source.
  • Data Mapper Text Reader component can skip specified number of lines before reading data.
  • Added Data Mapper DateAdd component.
  • Fixed path resolution issues in Data Mapper.
  • Fixed copy and paste issue in Data Mapper.
  • Includes rollup of all previous fixes. 
This update is free for user with a current Upgrade Support Protection Plan (USPP).

Try the new features with our free trial from:
https://www.liquid-technologies.com/trial-download