# How can I export from a nodered flow json file, the property "connection" of nodes with type "MSSQL"

**URL:** <https://discourse.nodered.org/t/how-can-i-export-from-a-nodered-flow-json-file-the-property-connection-of-nodes-with-type-mssql/94874>\
**Category:** General\
**Tags:** flows\
**Created:** [24 January 2025 12:20 UTC](https://discourse.nodered.org/t/how-can-i-export-from-a-nodered-flow-json-file-the-property-connection-of-nodes-with-type-mssql/94874 "2025-01-24T12:20:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dargento](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@dargento](https://discourse.nodered.org/u/dargento)\
**Post date:** [24 January 2025 12:20 UTC](https://discourse.nodered.org/t/how-can-i-export-from-a-nodered-flow-json-file-the-property-connection-of-nodes-with-type-mssql/94874/1 "2025-01-24T12:20:56Z")

</div>

I have an exported flows.json file of a NodeRed flow, and from that I want to parse the property "connection" of nodes with type "MSSQL". But I get always empty result. I have noticed when debugging the code that a property like "connection" is not existing programatically, although I can see it in the Nodered UI. Instead I can just parse the property "MSSQLCN" which is something like an ident number. How can I parse the node property "connection" via code using this "MSSQLCN" ident number? After that I would search for the global configuration node with that name and parse the properites "Server" and "Database"

```auto
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json.Linq;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            // Specify the path to the Node-RED flow.json file
            string inputFilePath = @"C:\flow.json";
            string outputFilePath = @"C:\result.txt";

            // Read the JSON file
            string jsonContent = File.ReadAllText(inputFilePath);

            // Parse the JSON content
            JArray flowArray = JArray.Parse(jsonContent);

            // List to store connection properties of MSSQL nodes
            List<string> mssqlConnections = new List<string>();

            // Iterate through each node in the flow
            foreach (JObject node in flowArray)
            {
                // Check if the node type is MSSQL
                if (node["type"]?.ToString() == "MSSQL")
                {
                    // Get the connection property
                    string connection = node["connection"]?.ToString();

                    if (!string.IsNullOrEmpty(connection))
                    {
                        mssqlConnections.Add(connection);
                    }
                }
            }

            // Write the connection properties to the output file
            File.WriteAllLines(outputFilePath, mssqlConnections);

            Console.WriteLine($"Extraction completed. Results saved to {outputFilePath}");
        }
        catch (Exception ex)
        {
            Console.WriteLine("An error occurred: " + ex.Message);
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 January 2025 12:30 UTC](https://discourse.nodered.org/t/how-can-i-export-from-a-nodered-flow-json-file-the-property-connection-of-nodes-with-type-mssql/94874/2 "2025-01-26T12:30:03Z")

</div>

A flow is a flat array of objects with each object representing a node.  
Every node object in a flow array has at minimum a `type` and an `id`  
When a node has a shared config node, it is identified by its `id`

e.g `regular-node` has a shared config and its id is `100000001`

```json
[
  { "type": "regular-node", "id": "100000000", "nodeConfig": "100000001" },
  { "type": "conf-node", "id": "100000001", "host": "localhost", "port": 1234, ... },
]

```

> [@dargento](#):
>
> I want to parse the property "connection" of nodes with type "MSSQL". But I get always empty result. I have noticed when debugging the code that a property like "connection" is not existing programatically, although I can see it in the Nodered UI. Instead I can just parse the property "MSSQLCN" which is something like an ident number

There is no strict convention (i.e. `connection` may or may not be the property that identifies the "Connection"). It is entirely down to how the node author wrote the contrib package.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 April 2025 12:30 UTC](https://discourse.nodered.org/t/how-can-i-export-from-a-nodered-flow-json-file-the-property-connection-of-nodes-with-type-mssql/94874/3 "2025-04-26T12:30:52Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
