Error in reading JSON in ADF

Mav 81 Reputation points
2023-07-11T00:24:08.1066667+00:00

Hi,

I am trying to read a JSON file that has yaml part in it.

In Copy data activity, reading the JSON file generates the following error

Error occurred when deserializing source JSON file 'aa.json'. Check if the data is in valid JSON object format.

After parsing a value an unexpected character was encountered: ". Path 'dddd', line 111, position 2.

The character is [

Is there a way we can read a JSON with yaml using ADF?

Azure SQL Database
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,623 questions
{count} votes

1 answer

Sort by: Most helpful
  1. QuantumCache 20,366 Reputation points Moderator
    2023-07-11T21:48:10.82+00:00

    Hello @Mav,

    Could you please add more info on the Source data, such as the JSON file sample which has the YAML part in it?

    Does the sample JSON looks like the below format?

    {
      "name": "John Doe",
      "age": 30,
      "address": {
        "street": "123 Main St",
        "city": "Anytown",
        "state": "CA",
        "zip": "12345"
      },
      "hobbies": [
        "reading",
        "writing",
        "yoga"
      ],
      "description": "This is a YAML string:\n---\nkey1: value1\nkey2: value2\nkey3:\n  - item1\n  - item2\n  - item3\n"
    }
    
    
    

    ADF supports reading JSON files that contain YAML parts, but the file must be in valid JSON format. The error message you are seeing suggests that the file is not in valid JSON format.

    To resolve this issue, you can try the following steps:

    Check the JSON file to ensure that it is in valid JSON format. You can use an online JSON validator to check the file.

    If the file is not in valid JSON format, you can try converting the YAML part to JSON format. There are online tools available that can help you with this conversion.

    Once the file is in valid JSON format, you can try reading it using the Copy Data activity in ADF.

    If you have already checked the file and it is in valid JSON format, then the issue may be with the specific JSON file you are trying to read. In this case, you can try creating a new JSON file with the same data and see if you are able to read it using the Copy Data activity in ADF.

    If you are still encountering issues, please provide more details about the JSON file and the Copy Data activity configuration, and I can help you further.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.