Is the JSON data not matching the file's content during validation?

After thorough testing, my JSON data appears to be functioning correctly with regular content.

Here is a sample of the working JSON:

Working Json

 {
  "language": "XYZ",
  "content": {
    "GEN": "this is test",
    "EXO": "this is test"
   }
 }

Not working json

 {
  "language": "XYZ",
  "content": {
    "GEN": "\id GEN\n\c 1\n\p\n\v 1 In the beginning God created the heavens and the earth.\n\v 2 And the earth was without form and was void form.",
    "EXO": "\id EXO\n\c 1\n\p\n\v 1 Now these are the names of the children of Israel, which came to Egypt; every man and his household came with Jacob\n\v 2 Reuben, Simeon, Levi, and Judah"
   }
}

You can view screenshots of both working and non-working JSON here.

Answer №1

JSON guidelines only allow certain backslash escape sequences such as \b, \f, \n, \r, \t and \". Any other instances of a backslash need to be escaped with \\. The issue arises when using escape sequences like \i which JSON does not recognize, resulting in a syntax error. It is recommended to use \\i instead.

Answer №2

To handle escape sequences, one approach is to convert your object into a JSON string and then parse it as shown in the example below:

 var obj= {
            "language": "XYZ",
            "content": {
                "GEN": "\id GEN\n\c 1\n\p\n\v 1 In the beginning God created the heavens and the earth.\n\v 2 And the earth was without form and was void form.",
                "EXO": "\id EXO\n\c 1\n\p\n\v 1 Now these are the names of the children of Israel, which came to Egypt; every man and his household came with Jacob\n\v 2 Reuben, Simeon, Levi, and Judah"
            }
        };
        var json= JSON.stringify(obj);

Using this method can simplify the process for you.

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

Here is a way to trigger a function when a select option is changed, passing the selected option as a parameter to the function

Is there a way to call a function with specific parameters when the value of a select element changes in Angular? <div class="col-sm-6 col-md-4"> <label class="mobileNumberLabel " for="mobilrNumber">Select Service</label> <div cla ...

Using JavaScript to auto-scroll a textarea to a certain position

Is there a way to change the cursor position in a textarea using JavaScript and automatically scroll the textarea so that the cursor is visible? I am currently using elem.selectionStart and elem.selectionEnd to move the cursor, but when it goes out of view ...

Obtaining targeted JSON data in Xcode 8 Swift 3.0 with the help of Alamofire

Here is some JSON data that I am working with: { "ID":"ID01", "pass":"1234", "mail":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0e6b636f67624e69206d6163">[email protected]</a>" } I am attempting ...

Just updated to Angular 10, encountered issue: Unable to modify the read-only property 'listName' of an object

After updating my Angular project from version 8 to version 10, I encountered an error while trying to edit an input field in a Material Dialog. The error message displayed is as follows: ERROR TypeError: Cannot assign to read only property 'listName& ...

ReactJS Error: Rendering objects as a React child is not supported. If you intended to render multiple children, make sure to use an array instead

customMovieService.js: const films = [ { _id: "5b21ca3eeb7f6fbccd471815", title: "Inception", genre: { _id: "5b21ca3eeb7f6fbccd471818", name: "Sci-Fi" }, numberInStock: 8, dailyRentalRate: 2.0, publishDate: "2019-07-15T14:36:40.8 ...

IsContainer and IsModel properties in Dragular are not functioning properly with the accept or canBeAccepted methods

Scenario 1 : Let's consider using two containers, named A (Drag Source) and B (Drop Source). Code snippet : dragularService(containerLeft, { containersModel: [DragularconTainer], copy: true, canBeAccepted: function(el, source) { ...

The getStaticProps function will generate an object by fetching data from various URLs

Within my getStaticProps function in next js, I am faced with the challenge of fetching multiple dynamic URLs and exporting the results as props to the component. As these URLs are automatically generated, I do not know how many there will be to fetch. My ...

Is it possible to transfer files using web-bluetooth technology?

As I work on developing an embedded system that counts the number of cars, saves their speed and time data in a logs file using rsyslog. Simultaneously, I am creating a web-API (in Typescript/Angular with Electron for Desktop usage and later Web as well) t ...

Add a CSS and jQuery hover effect to display text over an image, requiring users to click twice on their mobile device

I have a bunch of panels for different categories that change the background image when hovered over, display some introductory text, and lead to a URL when clicked. However, on mobile devices, you need to tap the panel twice to activate the URL. What I&a ...

What could be causing the abortTransaction() method in mongoose to not function as

System OS: MacOS 10.15.5 NodeJS Version: 10.16.3 Mongoose Versions: 5.8, 5.9 MongoDB Version: 4.0.3 The following code snippet is in question: import User from 'models/user' const session = await User.startSession() session.startTransaction() ...

Embedding HTML Tags within an array element

The task at hand involves adding an HTML element from Array Value to the Document Object Model template: { 0: { h1: '<h1>Hi</h1>' }, 1: { h2: '<h2>Hi</h2>' }, 2: { h3: &a ...

Manage and update events in the Angular Bootstrap Calendar

For the past few days, I have been working on integrating a calendar into my project. I decided to repurpose an example provided by the developer. One issue that I've come across is related to the functionality of deleting events when using the dropdo ...

Formatting Dates in Node.js

Can someone assist me in understanding how to properly format the print date shown below? Thu Sep 06 2018 18:18:26 GMT+0530 I attempted to use console.log(new Date()) However, the output generated was 2018-09-06T12:48:25.776Z I am unsure of how to co ...

What could be the reason for my code generating the error [$http:badreq]?

I'm currently attempting to retrieve JSON data from a certain URL and am having trouble getting it to work. Despite going through the Angular documentation and other resources, I still can't pinpoint the issue due to my limited experience with An ...

Combining JSON objects in MySQL using the primary key specified in a JSON document

I'm looking to perform atomic UPDATEs on a JSON column that stores documents. The challenge lies in updating the column with precision and efficiency. Consider the initial value: [{"substanceId": 182, "text": "substance_name_182"}, {"substanceId": 1 ...

What steps can I take to pinpoint the exact error location when running assetic:dump in Symfony2?

This error message indicates an issue with assetic:dump in Symfony2. [Assetic\Exception\FilterException] ...

Guide to activating the timer specifically on select pages with jQuery Mobile

I've developed a quiz application using jQuery Mobile and I am working on implementing a timer feature. The timer should run from 0 seconds up to 1 hour but only when the user is viewing specific pages, specifically the question pages. The timer is di ...

Continuously looping through the function based on availability in Symbol ES6

When using the ES6 Symbols iterator, I found that I needed to call the next function each time to print the next item during iteration. Below is the code snippet: var title = "Omkar"; var iterateIt = console.log(typeof title[Symbol.iterator]); var iter ...

Obtain asynchronous state in VueJS without the need for intricate v-if conditions

I am working on an application that heavily relies on Vue-Router and Vuex for state management. Within the Dashboard component, important user information is displayed. This data is fetched asynchronously from a database by Vue and then stored in Vuex. T ...

Diverse Browser Image Mapping Coordinates

I am in the process of creating an image map, where I specify coordinates on an image that link to other pages. However, I'm encountering an issue where the position of these coordinates is not relative. When viewing the image on a different browser ...