"Encountered a Json error with a bizarre character causing the string

After extracting some json data from a website, I encountered an issue when trying to parse it using vscode. I kept getting an 'unexpected end of string' error on the "content" line: Here is the json:

    {
    "name": "Anna Vergnas",
    "date": "04/18/2018 4:30pm",
    "content": "L'appartement se situe au métro porte de Montreuil.Nous sommes au rez de chaussée d 'une belle et grande cour pavée, qui accueille volontier une baignade de soleil, des apéros au milieu des jardinières et . Cadre plutôt exceptionnel pour Paris, puisque vous avez un jardin et une terrasse dont vous profitez as you want (dans le respect de chacun).Pour plus d'
    info contactez moi en mp: )",
"number" : "null"}

This snippet shows part of the code used for scraping ( blocks is the div of the container):

let result = []

                let name = blocks[z].querySelector('.fwn.fcg') ? blocks[z].querySelector('.fwn.fcg').innerText : null
            let fb_url = blocks[z].querySelector('h5 a') ? blocks[z].querySelector('h5 a').href : null
            let date = blocks[z].querySelector('abbr') ? blocks[z].querySelector('abbr').title : null
            let content = blocks[z].querySelector('._5pbx.userContent._3576') ? blocks[z].querySelector('._5pbx.userContent._3576').innerText : null
            let number = blocks[z].querySelector('._5pbx.userContent._3576') ? blocks[z].querySelector('._5pbx.userContent._3576').innerText.replace(/\s/g, '').match(/((\+)33|0)[1-9](\d{2}){4}/g) : null
            result.push({ name, fb_url, date, content, number, group_url})

Answer №1

I noticed in your message that the data includes a new line that is not properly encoded, violating the JSON format.

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

Combine multiple key values from an array of objects into a single array

I have a set of key and value pairs that I need to filter based on whether the values are in an array or not, and then combine them into a single array. const holiday_expenses = { food: [{name: "abc", place: "xyz"}], travel: [{name: ...

How to Use Json.net to Deserialize an Array of Arrays Containing Classes

I have been receiving JSON data from a URL in the following format: { "destination_addresses" : [ "example address" ], "origin_addresses" : [ "example address" ], "rows" : [ ...

Unable to detect the click event on Bootstrap accordion

I am currently utilizing Bootstrap to populate a table with data and then attempting to capture an accordion show event. My intention is to extract the div id in order to make an ajax call for more information on the respective item. Unfortunately, I have ...

The array filtering functionality is not functioning as intended

Struggling with correctly filtering data in JavaScript. Here's an example where var1 = 20, var2 = 10, var3 = 30, var4 = 40. This is the code snippet: var variables = ['var1', 'var2', 'var3', 'var4'], values = [ ...

detect mouse click coordinates within an iframe that spans multiple domains

I am currently encountering an issue with tracking click position over a cross-domain iframe. Here is my current code: <div class="poin"> <iframe width="640" height="360" src="http://cross_domain" frameborder="0" allowfullscreen id="video">< ...

NuxtJS (Vue) loop displaying inaccurate information

I have a dataset that includes multiple languages and their corresponding pages. export const myData = [ { id: 1, lang: "it", items: [ { id: 1, title: "IT Page1", }, { ...

AngularJS allows for the creation of 2D arrays using the $Index

Currently, I am working on a project using AngularJS that involves creating a spreadsheet from a 2D array generated by the ng-repeat function. As part of this project, I am developing a function to update the initial values of the array when users input ne ...

Determine if the highest value in the array is at least double the size of all other numbers within the array

I am attempting to create a program that identifies the index of a number in an array that is at least twice as large as all other numbers. Below is the code I have written: def dominantIndex(self, nums): max_num = max(nums) max_i =nums. ...

Converting JSON to POJO using GSON fails to retrieve the value and returns as null

Greetings, I've recently started using the Loopj and GSON libraries for handling Web Service responses. However, I'm facing some difficulties in extracting values from GSON to my POJO. I'm struggling to understand how to retrieve values fro ...

NG6002 error: This error is showing up in the imports of AppModule, even though it has its own set of issues

Running Angular 12 locally is smooth with no errors in the project build. Local Configuration: Angular CLI: 12.0.5 Node: 12.16.3 Package Manager: npm 6.14.4 OS: win32 x64 Angular: 12.0.5 However, when attempting to build the project on a Linux se ...

directive in Angular ordering

After exploring this link, my understanding deepened: http://plnkr.co/edit/k5fHMU?p=preview Upon analyzing the code snippet provided in the link above, I noticed that the Angular app consists of both a controller and a directive. However, there seems to ...

Receiving an error while trying to install packages from the NPM registry due to non

I am facing some challenges while attempting to install my Ionic App through the registry along with its dependencies. I have been using npm i --loglevel verbose command, and my ~/.npmrc file is configured as follows: //nexus.OMMITED.com/repository/:_auth ...

Different choices for data attributes in React

Recently, I downloaded a new app that requires multiple API calls. The first API call retrieves 20 Objects, each with its own unique ID. The second API call is made based on the IDs from the first call. To display this data in my component: <div> ...

Connecting to a specific mui-tab with react-router-dom

How can I link to a specific tab in my material ui-based tabs setup within a React application? I want to be able to navigate directly to a particular tab when landing on the page, but I'm struggling with integrating this functionality. Is there a way ...

The process of deserializing WCF JSON data using JavaScriptSerializer is being delayed

I've been working on deserializing a large JSON response in a WCF application using a generic method. However, the process is taking an unexpectedly long time to handle approximately 5 MB of data. During program execution, I consistently encounter a ...

Converting milliseconds into a formatted DateTime using AngularJS: A step-by-step guide

Upon receiving JSON data from the server, I obtained a date-time in milliseconds: $scope.JDT = "1492499995056";. While I am able to display the scope variable 'JDT' on my view using a filter: {{JDT | date:"dd/MM/yyyy h:mm:ss a"}} ... I do not a ...

Text area containing an unspecified value within a webpage featuring interactive forms

I'm struggling to understand why I can't access the field values on forms that are generated dynamically through AJAX and MySQL. The structure of the form template is as follows: <form class="dishform" id='" + d.dish_id + "FF' acti ...

The retrieved information can be seen in the Network tab, however, there seems to be an issue in the console

I am successfully fetching data from the server, but I can't seem to display it in console.log. The error message I'm encountering is shown below. I have confirmed that the data is being returned as an array. What steps should I take to ensure th ...

Executing an ajax post when a user clicks on a link or button

<tr> <td> <span id="id_1"> <a href="/Path" >Name</a> <a href="#">Delete</a> </span> </td> &l ...

Reposition HTML elements using JavaScript

Is there a way to use JavaScript or jQuery to replace the image with class "fnone" located under the span element with class "ddlabel"? <span id="flat_title" class="ddTitleText "> <img class="fnone" src="images/pinc.png"> <span ...