Error detected in JSON syntax... Where is it hiding?

After running the code through jsonlint, it flagged an error on line 17. However, upon close inspection of the file which contains about 1000 lines, I couldn't pinpoint the issue. It's possible that the problem lies further down the file, but I wanted to reach out to the community here for assistance since no errors are visible to me at the moment.

{
    "Blue Tag" : {
        "Queries" : {
            "DepartmentID" : {
                "name" : "Departments",
                "params" : ["1"],
                "options": []
            },
            "ZoneID" : {
                "name" : "Zones",
                "params" : [
                    "1",
                    "Department" : { // encountering an error in this section
                        "ref" : "true", 
                        "returns" : "value"
                    }
                ],
                "options": []
            },
            "MachineID" : {
                "name" : "Machines",
                "params" : [
                    "1",
                    "Department" : { 
                        "ref" : true, 
                        "returns" : "value"
                    },
                    "Zone" : { 
                        "ref" : true, 
                        "returns" : "value"
                    }
                ],
                "options": []
            }
        },
        "Emails" : ["*@*.com","*@*.com"],
        "PK" : "ID",
        "Table" : "BlueTags",
        "Connection" : "Safety"
    }
}

The specific error message received is as follows:

Parse error on line 17:
...        "Department": {                
-----------------------^
Expecting '}', ',', ']'

Answer №1

"settings" : [
    "1",
    "Department" : { 
        "ref" : "true", 
        "returns" : "value"
    }
]

This array is structured as a list, not an object. Replace the [] with {}

"settings" : { // <- By using curly brackets, we create an object with key:value pairs
    "1" : "",
    "Department" : { 
        "ref" : "true", 
        "returns" : "value"
    }
}

Alternatively, if you prefer to maintain the settings as an indexed array

"settings" : [ // <- Square brackets indicate an array containing values (which can also be objects)
    "1",
    {"ref" : "true", "returns" : "value"}
]

Answer №2

Maybe you simply overlooked adding brackets to enclose your objects within the params arrays

"params" : [
    "1",
    {"Department" : { 
        "ref" : true, 
        "returns" : "value"
    }},
    {"Zone" : { 
        "ref" : true, 
        "returns" : "value"
    }}
],

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using AJAX call and jquery each loop to work with JSON syntax

I made an AJAX request that fetches data from PHP. echo json_encode($json_response); The output looks like this: [{"name":"Sprouts.......}] Next, I used JQUERY to iterate through the data using the following code: $.each($.parseJSON(data), function(i, ...

I am looking to transmit a JWT token to my backend using next-auth

In my current project using Next.js, I have implemented authentication with next-auth. This project follows the MERN stack architecture. I am facing an issue where I need to retrieve the JWT token and send it to my backend server using next-auth along wit ...

The specified method is not recognized as a function in the ReactJS library

Within my reactJS application, there is a function that calls upon a helper function to retrieve the result of a calculation. The component looks like this: import React, { Component } from "react"; import * as d3 from "d3"; class DrawImage extends Comp ...

Tips for quietly printing a PDF document in reactjs?

const pdfURL = "anotherurl.com/document.pdf"; const handleDirectPrint = (e: React.FormEvent) => { e.preventDefault(); const newWin: Window | null = window.open(pdfURL); if (newWin) { newWin.onload = () => ...

What is the best way to determine the width of a scroll bar?

Are you familiar with any techniques that work across multiple browsers? ...

What is the best way to show and hide the information in a FAQ section when each one is clicked?

const faqItems = document.getElementsByClassName("faq-question"); const faqContents = document.getElementsByClassName("faq-content"); for (item of faqItems) { console.log(item); item.addEventListene ...

Having to click twice in order to close the jQuery dialog box can be frustrating

I've been attempting to set up a div that pops up using jQuery dialog. Initially, when the user clicks on the button and opens the dialog, it closes with the first click. The second time they try to close the dialog, it will reopen the same popup, r ...

Refine your search by name following the implementation of a character-altering filter

Encountered a scenario in which there is a need to filter elements generated by the 'ng-repeat' directive. I have implemented a custom filter that replaces one character with another and vice versa for each element created. However, when attempt ...

NextJS rendering props in a loop

I need help figuring out how to render props in a loop using the forEach function. This is my current code: {console.log('the catalog inside the component ----->', catalog)} {Object.keys(catalog).forEach(key => { return ( <d ...

Improper menu alignment following a MenuItem hover event within Material-UI

When a MenuItem is hovered over, the position of the Menu container should remain unchanged. [x] The issue persists in the most recent release. However, downgrading MUI to v4.5.0 results in the expected behavior. Current Behavior ...

What is the best way to handle various sections with changing structures within a complex form using react-hook-form?

I am working on a complex form that has sections A, B, and C, each of which can be in shape A1 or A2, B1 or B2, C1, or C2. Users are required to fill out settings based on whether the section is set to "advanced" or "basic". I want users to submit the enti ...

Avoiding external variable reference through Jest.mock

For snapshot testing, I need to create a simple dummy mock of 1 react component. When attempting to use React.Component within the mock function, an error is thrown: The second argument of jest.mock() cannot reference external variables. However, usin ...

Passing data to server-side PHP script using AJAX technology

Currently, I'm facing an issue with passing variables to a PHP script using onclick. It seems that I am making a mistake somewhere. To demonstrate the problem, let's say I have the following code snippet in my main page: <img src="myImage.jp ...

What is the best way to sequentially add a child to a parent in firebase?

Can someone help me with a problem I'm facing regarding storing data in a specific format? { "rsvp":[ {"event": "event1","name": "name1","rsvp": "going"}, {"event": "event2","name": "name2","rsvp": "going"} ] } I want to save the data in the above ...

How to handle a hefty Json file (roughly 50Mb) with Kotlin

I've embarked on a project to create a weather application using the API from "openweathermap.org," which offers a list of cities in Json format for developers to utilize. However, I've encountered an issue while trying to read and parse the Jso ...

Generate a JSON file in Python using a for loop and store a variable in the JSON structure

I'm fairly new to working with Json files. I would like to create a Json file containing 10 JSON objects, each representing data from a sensor such as temperature, flow, and pressure. The values for each parameter are currently stored in variables. Ho ...

The conundrum of jsPDF's image compatibility

I am attempting to generate a PDF document on the client-side using the jsPDF library. The code I have written is as follows: <script type="text/javascript" src="libs/base64.js"></script> <script type="text/javascript" src="libs/sprintf.js" ...

Is it possible to override values set in the constructor(props) in React? If not, what is the best way to set defaults that can be overwritten later?

I'm confident I know the solution to this problem because my setState({}) seems to have no effect. This is the constructor code that I currently have: constructor(props) { super(props); this.state = { percentiles: { incN ...

How to Animate the Deletion of an Angular Component in Motion?

This stackblitz demonstration showcases an animation where clicking on Create success causes the components view to smoothly transition from opacity 0 to opacity 1 over a duration of 5 seconds. If we clear the container using this.container.clear(), the r ...

What is the best way to transfer properties to a different component using the onClick event triggered by an element generated within the map function?

I am currently working on an application using react to retrieve data from a mongodb database. Within one of the components, called Gallery, I have integrated a map function to display a list of items. My goal is to implement an onClick event for each elem ...