Text Parsing JSON XML CSV

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 10 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Mastering Text Parsing: Handling JSON, XML, and CSV in Cloud Flows

Introduction: The Critical Role of Data Serialization

In the world of modern automation, data is rarely delivered in a format that is ready for immediate human consumption. Instead, systems communicate using structured data formats—specifically JSON, XML, and CSV—to exchange information across networks, APIs, and file systems. As an automation developer, your ability to "parse" this data is the difference between a functional workflow and a broken one. Parsing is the process of taking a raw string of text and converting it into a structured format that your automation platform can read, manipulate, and act upon.

Why does this matter? Imagine you are building a flow that pulls customer information from an external CRM. The API might return a long string of text wrapped in braces and brackets. If you treat that as a simple block of text, you cannot easily extract the customer's email address, order history, or shipping status. By mastering text parsing, you gain the ability to reach inside these data structures, pull out specific values, and use them to trigger actions like sending emails, updating databases, or generating invoices. This lesson will walk you through the mechanics of handling these three dominant data formats within cloud-based automation environments.


Not read yet

1. Understanding JSON: The Industry Standard for Web Data

JSON (JavaScript Object Notation) has become the de facto language of the internet. It is lightweight, easy for humans to read, and remarkably simple for machines to parse. In a cloud flow, you will encounter JSON every time you call an HTTP request or receive a webhook notification.

Structure of JSON

JSON is composed of key-value pairs. Keys are always strings enclosed in double quotes, while values can be strings, numbers, booleans, arrays, or nested objects. Understanding this hierarchy is essential because your automation platform will rely on this structure to map data fields.

Parsing JSON in Cloud Flows

Most modern automation platforms include a "Parse JSON" action. This action requires two inputs: the content (the raw string) and the schema (the blueprint of what the data looks like).

Callout: Why Schema Matters The schema is a set of rules that defines the expected structure of your JSON. Without a schema, the automation platform treats the data as a generic string. By providing a schema, you allow the platform to generate dynamic content tokens for every field in the JSON, making it possible to select "CustomerName" or "OrderTotal" directly from a list in your flow builder.

Step-by-Step: Parsing JSON

  1. Receive the Input: Use an HTTP action or a Webhook trigger to obtain the raw JSON string.
  2. Add the Parse JSON Action: Add the action to your flow and map the output from the previous step to the "Content" field.
  3. Generate from Sample: Rather than writing the schema manually, click the "Generate from sample" button. Paste a representative JSON string into the dialog box. The platform will automatically calculate the data types (string, integer, array, etc.).
  4. Use the Output: Once the schema is saved, you will see the individual fields available in your dynamic content selector for subsequent steps in your flow.

Tip: If you are unsure about the structure of an incoming JSON, use a tool like an online JSON validator to ensure it is correctly formatted before attempting to parse it in your flow. A single missing comma or unclosed bracket will cause the entire parsing action to fail.


Not read yet

2. Navigating XML: The Enterprise Data Language

While JSON dominates web APIs, XML (eXtensible Markup Language) remains deeply embedded in legacy systems, financial services, and document management workflows. XML uses a tag-based structure similar to HTML, which can be more verbose but offers strong support for complex data relationships and metadata.

The Challenge with XML

XML is inherently hierarchical. Parsing XML in cloud flows often requires a different approach than JSON because XML can contain attributes, namespaces, and nested elements that don't map cleanly to simple flat variables.

Parsing XML with XPath

To extract data from an XML payload, you often use XPath (XML Path Language). XPath allows you to navigate through elements and attributes in an XML document. Think of it like a file path for your data.

Example XML Structure:

<Order>
    <ID>1001</ID>
    <Customer>
        <Name>Jane Doe</Name>
        <Email>[email protected]</Email>
    </Customer>
</Order>

To extract the email, your XPath expression would look like: /Order/Customer/Email.

Best Practices for XML

  • Keep it Simple: If you have the choice, prefer JSON over XML for new integrations. If you must use XML, try to use a "Convert XML to JSON" action first if your platform supports it. This often makes the data much easier to work with using standard JSON parsing techniques.
  • Namespace Awareness: Many XML documents use namespaces (e.g., xmlns:xsi="http://..."). These can break simple parsing logic. Always check if your XML has a namespace definition at the top, as you may need to account for it in your XPath queries.

Warning: Be cautious with deep nesting. If an XML file is extremely large or deeply nested, parsing it in a standard cloud flow may hit memory limits or execution time constraints. In such cases, consider using a dedicated serverless function or an integration service that is designed to handle large file processing.


Not read yet

3. Handling CSV: The Spreadsheet Standard

CSV (Comma-Separated Values) is the most common format for bulk data transfer. Unlike JSON and XML, CSV is flat. It relies on a header row to define column names and subsequent rows to provide the data.

Parsing CSV in Cloud Flows

Parsing CSV is fundamentally different because you are dealing with a table of data rather than a single object. You have two main options when working with CSV in cloud flows:

  1. The "Parse CSV" Action: Many platforms have a native action that takes a CSV file and converts it into a JSON array. This is the preferred method for most users.
  2. Manual Splitting: If a native action is not available, you can use string functions to split the data by newlines (to get rows) and then by commas (to get columns).

The "Gotchas" of CSV Parsing

CSV seems simple, but it is prone to data quality issues that can break your flow:

  • The Comma Problem: What happens if a field contains a comma? (e.g., "New York, NY"). Standard CSV uses quotes to wrap these fields, but if your parser isn't configured to handle quotes, it will split the city and state into two separate columns.
  • Header Mismatches: If the source system changes the column header name (e.g., changing "Cust_Name" to "Customer Name"), your flow will likely fail to map the data correctly. Always validate headers before processing rows.

Callout: JSON vs. CSV for Automation

  • JSON: Best for hierarchical, complex data; native to APIs; easy to parse with schema.
  • CSV: Best for bulk, tabular data; easy to view in Excel; requires careful handling of delimiters and character escaping.

Not read yet

4. Practical Implementation: A Scenario-Based Approach

Let's walk through a scenario where you need to parse data from a legacy system that exports a CSV file, convert it to a JSON object, and then push that data to a modern API.

Step 1: Ingest the File

Use a "Get file content" action to pull the CSV from a storage provider (like SharePoint, OneDrive, or an FTP server).

Step 2: Convert to JSON

Use the "Parse CSV" action. Ensure you specify the delimiter (usually a comma) and indicate whether the first row contains headers. This action will produce an array of objects.

Step 3: Iterate and Transform

Use an "Apply to Each" loop to process the array. Inside the loop, you can map the specific CSV columns to the JSON structure required by your target API.

Example Code Snippet (Pseudocode for data transformation):

For each Row in CSV_Array:
  Create JSON Object:
    {
      "customer_id": Row['ID'],
      "full_name": Row['Name'],
      "contact_method": "email"
    }
  HTTP POST (API_Endpoint, Body: JSON_Object)

Step 4: Error Handling

Wrap your HTTP action in a "Configure Run After" setting. If the API call fails because of a malformed JSON object, you can trigger a notification or log the error to a secondary file for manual review.


Not read yet

5. Common Pitfalls and How to Avoid Them

Even experienced developers encounter issues when parsing data. Here are the most frequent mistakes and how to prevent them.

Pitfall 1: Assuming Consistent Data

Never assume that the data coming from an external source will always be perfectly formatted. A missing field or an unexpected null value can crash a flow.

  • The Solution: Use conditional checks. Before trying to access a field, use an "If" condition to check if the value is null or empty. Use the coalesce() function to provide a default value if a field is missing.

Pitfall 2: Encoding Issues

XML and JSON are typically UTF-8, but CSV files are often generated by older systems in different encodings (like Windows-1252). This can lead to "mojibake"—where special characters like symbols or accented letters turn into gibberish.

  • The Solution: Always verify the file encoding. If possible, convert files to UTF-8 before processing them in your flow.

Pitfall 3: Ignoring Rate Limits

When parsing large files and looping through them, you are performing many actions in a short period. This can trigger API rate limits on your automation platform.

  • The Solution: Use "Batching." Instead of processing one record at a time, see if the target API accepts a bulk upload. If not, use a "Delay" action to stagger the execution of your loop.

Not read yet

6. Advanced Techniques: Dynamic Parsing

As you become more comfortable with parsing, you may need to handle data that doesn't follow a predictable schema. This is common when working with "web scrapers" or unstructured text files.

Using Regular Expressions (Regex)

Regex is a powerful tool for finding patterns in text. If you have a block of text and you need to extract a specific pattern (like an invoice number that always starts with "INV-" followed by 5 digits), you can use a Regex match action.

Regex Example: INV-\d{5}

  • INV-: Matches the literal characters.
  • \d{5}: Matches exactly five digits.

When to Use Regex

  • Extracting hidden IDs: When a system embeds a unique ID inside a larger string.
  • Data Cleaning: Removing unwanted characters from a string before parsing it into JSON.
  • Validation: Ensuring a user-provided string meets your data format requirements before proceeding.

Note: Regex can become complex very quickly. Keep your expressions simple and document them. If you find yourself writing a regex that is longer than two lines, you are likely making it too complicated and should rethink your data extraction strategy.


Not read yet

7. Comparison Table: Parsing Methods

Method Best For Complexity Pros Cons
Parse JSON Action APIs, Webhooks Low Fast, native support Requires rigid schema
XPath Legacy XML systems Medium Precise navigation Steep learning curve
CSV Parser Bulk data, reports Low Handles tabular data Sensitive to delimiters
Regex Unstructured text High Extremely flexible Hard to debug/maintain

8. Best Practices for Professional Workflows

  1. Schema Validation: Always validate your JSON against a schema. It turns a "black box" of data into a documented, typed structure that your team can understand.
  2. Error Logging: If a parsing action fails, don't just let the flow stop. Create a "Catch" block that saves the raw input to a text file. This allows you to inspect the data that caused the failure later.
  3. Environment Separation: Never test parsing logic against live production data. Create a "test" folder where you can drop sample files to verify your flow logic before deploying it to handle real business operations.
  4. Documentation: If you are using complex XPath or Regex, add a comment in your flow describing what the expression is intended to do. Future developers (or your future self) will thank you.
  5. Security: Be careful when parsing data from external sources. If you are parsing JSON and passing it into a database query, ensure you are sanitizing the input to prevent injection attacks.

Not read yet

9. FAQ: Common Questions from Developers

Q: My JSON parsing action is failing, but the JSON looks correct. What could be wrong? A: Check for hidden characters. Sometimes JSON exported from systems contains invisible "Byte Order Mark" (BOM) characters or non-breaking spaces that break standard parsers. Try stripping whitespace from the string before parsing it.

Q: How do I handle a JSON array of objects instead of a single object? A: Most "Parse JSON" actions will automatically detect an array if you provide an array as your sample. If it doesn't, you may need to wrap your content in a parent object or use a "Select" or "Filter Array" action to manipulate the data before parsing.

Q: Is there a limit to how large a CSV file can be for parsing? A: Yes. Most cloud flow platforms have limits on the size of the payload (often around 100MB). If you are processing a massive CSV file, you should break it into smaller chunks or use a dedicated data processing service (like an Azure Function or AWS Lambda) instead of a standard flow.

Q: Can I use these techniques for HTML? A: You can use XPath to parse HTML, as HTML is essentially a specific type of XML. However, be aware that many websites have "malformed" HTML that will cause standard XML parsers to fail. For web scraping, it is better to use dedicated libraries that are designed to handle "tag soup" (dirty HTML).


Not read yet

10. Key Takeaways

After completing this lesson, you should have a solid foundation for handling the most common data formats in your cloud automations. Remember these core principles:

  • Structure is Everything: Whether it is JSON, XML, or CSV, your success depends on understanding the structure of the data before you attempt to process it. Always obtain a sample file or API response first.
  • The Schema is Your Friend: For JSON, always define a schema. It transforms opaque strings into accessible, typed variables that you can use throughout your flow.
  • Respect the Format: Treat CSVs with caution by verifying delimiters, XML with care by checking for namespaces, and JSON with accuracy by validating the structure.
  • Expect the Unexpected: Data from external systems will eventually fail or change. Build your flows with robust error handling, logging, and validation to ensure they are resilient.
  • Use the Right Tool: Don't try to parse everything with Regex. Use the native actions provided by your platform first, and only move to advanced string manipulation or custom code when those built-in tools prove insufficient.
  • Test in Isolation: Always test your parsing logic with controlled, sample data before connecting it to live production systems.
  • Think About Scale: Always consider whether your parsing method will hold up under high volume. If you are processing thousands of rows, ensure your flow is optimized for performance rather than just functionality.

By mastering these techniques, you are moving beyond simple "point-and-click" automation and into the realm of professional data engineering. You now have the skills to integrate disparate systems, clean messy data, and ensure that your automations are both reliable and efficient. Continue to experiment with different file types and data structures, and always keep your logic clean and well-documented.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.