Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
How to interpret extended json data

Description of the problem

I will not write any codes as much of my problem is something linked with the knowledge to interpret some data. I am doing a project and had to use a nonsql database to store data the sampled information from a microcontroller. The chosen db was mondodb. I wrote all the code that stores the info and now i want to exhibit the date on a html page. The problem is that when i do the request using restapi to the mongodb, the json that was stored there comes in the extened json format, i.e.:

  "_id": {
            "$oid": "6230d05dcf81542c5aabc30b"
        },
        "sensor": {
            "$numberDouble": "1"
        }

But it should have come as the data is stored in the db:

  
"{
  _id":  "6230d05dcf81542c5aabc30b",
  "sensor": 1.0
  }     

As you can see, the the json comes with extra information linked to the type of the variable that is stored. But i don't really know how to use that information in javascript. I would just read it for example as json.sensor.$numberDouble if i wanted to get the information about the sensor instead of json.sensor if the json was in the normal way. I don't see much of an use to the extended version. Is something i am doing wrong?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Make sure, that you Parse API response, like-

response.json()
about 4 years ago · Juan Pablo Isaza Report

0

It looks like you're getting back an EJSON response. If you want to send back standard JSON response then that should be set as the Content-Type on the server response.

function(req, res) {
    data = { ... }; // Your data here
    res.setHeader("Content-Type", "application/json");
    res.setBody(JSON.stringify(data));
}

If you don't have control over the server side, then convert the EJSON back to plain JSON using the meteor EJSON library.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!