Is there a way to access a JSON property that contains multiple spaces in its name?

"technicalData": [
      {
        "Technologie": "Bluetooth Low Energy 4.0",
        "Größe (L x B x H)": "34.4 x 32.5 x 13 mm",
        "Gewicht": "018 kg",
        "Software": "Required for work, but not included. Register for free software use and premium services at: www.bosch-trackmytools.com",
        "Batterie": "CR 2032",
        "Batterie Lebensdauer": "3 J",
        "IP Schutzklasse": "IP 67",
        "Robustheit": "IK 04",
        "Befestigung": "2-component adhesive or cable holder GCA 30-9 Professional"
      }
    ]

I am having trouble retrieving the information for "Größe (L x B x H)" due to multiple spaces, ["naming it"] method is ineffective in this case

Answer №1

Before proceeding, it is important to correctly define your json dictionary in the following manner:

json_dict = {"technicalData": [
      {
        "Technology": "Bluetooth Low Energy 4.0",
        "Dimensions (L x W x H)": "34.4 x 32.5 x 13 mm",
        "Weight": "018 kg",
        "Software": "Required for operation but not included. Register for free software usage and premium services at: www.bosch-trackmytools.com",
        "Battery": "CR 2032",
        "Battery Life": "3 years",
        "IP Protection Class": "IP 67",
        "Robustness": "IK 04",
        "Attachment": "2-component adhesive or cable holder GCA 30-9 Professional"
      }
    ]
}

Subsequently, you can retrieve the specific property using this print() statement. Note that the desired data is nested within an array!

print(json_dict['technicalData'][0]['Dimensions (L x W x H)'])
# 34.4 x 32.5 x 13 mm

Answer №2

Hey, you should encounter no issues with this. Just remember your json is nested inside an array. I'm confident that if you follow these instructions, you'll be good to go.

technicalData[0]["Größe (L x B x H)"]

This command will yield "34.4 x 32.5 x 13mm"

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

Enhancing the performance of sortable array and object structures in Javascript

When working with objects in javascript and needing to maintain a specific sort order, key/value pairs cannot be used. Instead, utilizing an array with features like ES6 map is more suitable. An example structure that could be used is shown below. The id ...

The behavior of a fixed position in Flexbox varies when comparing Chrome to Safari and Firefox

In Chrome, the following code works as expected, with the list element positioning itself at the very left of the .PageContainer when scrolling down. However, in Safari and Firefox, the list element positions itself just after the logo. Are there any CSS r ...

What is the best approach for choosing unquoted HTML attribute values?

I have a unique situation where I am dynamically appending a select element to a form from a hidden field, with escaped spaces in the element content. This is the hidden field content: <input type="hidden" id="field1" name="field1" value="<select i ...

Backup search outcomes as JSON into a document on the network drive

Although I am capable of saving the results as JSON, I am encountering an issue when attempting to save it to a network drive. To verify that the path is correct, I utilized the following code snippet: if ($handle = opendir('//network/IS/folder1/fol ...

Adjust the point color of landmarks in Face-api.js

I need to customize the pointColor and lineColor in my code, but I'm not sure how to do it. I am using the fast-api.js library and haven't come across any examples of customized Landmarks Styles. export const drawResults = async (image, canvas, r ...

Create a string representing the path to access a property within a nested object

I am dealing with an object that has nested properties: { x: { y: { z: { min: 1, max: 2 }, w: 5 } } } The levels of nesting can vary. It can end with an object containing properties like 'min' ...

Creating scrollable content using JavaScript within a container with a hidden overflow

I am looking for a solution to efficiently display numerous image thumbnails within a limited space. My plan is to organize the thumbnails into 3 columns with an undetermined number of rows. I intend to place this content inside a viewport div, structured ...

When contextIsolation is set to true in an Electron application, React components fail to render properly. However, they render without any issues when context

I am currently in the process of learning the react framework and transitioning my electron application from a standard Electron + HTML/CSS setup to incorporate React. However, I have encountered an issue where setting contextIsolation to true for preload. ...

Vue.js and the hidden input value that remains unseen

I am currently developing a shopping list application using Vue.js and I was wondering if there is a conventional method to achieve my requirements. My app consists of a list of items with add and delete buttons: https://i.stack.imgur.com/yQfcz.png const ...

What is the TypeScript equivalent of the Java interface.class?

Can you write a Java code in TypeScript that achieves the same functionality as the code below: Class<?> meta = Object.class; and meta = Processor.class; // Processor is an interface In TypeScript, what would be the equivalent of .class? Specifica ...

Printing null with Android JSONObject is necessary

information from: {"i":"One","o":"two","u":"","a":"four"} script snippet: JSONObject data; for (int i = 0; i < list.length(); i++) { data = list.optJSONObject(i); mSearchList.add(data.optString("o") + " " + data.optString("u")+ " " + ...

Retrieve Next Element with XPath

I recently started working with XPATH and have a few questions about its capabilities and whether it can achieve what I need. The XML Document structure I am dealing with is as follows: <root> <top id="1"> <item id="1"> < ...

Vue.js is prevented by Content-Security-Policy

Running a HTML page on my node.js server with express.public() function. I included the following in my html page: <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> However, Chrome gave me a Content-Security-Pol ...

I am looking for information on how to properly handle HTTP errors in Axios when utilizing a blob responseType in VueJs

Using the blob responseType with Axios in my VueJS app allows me to download a document from the server. Everything works fine when the response code is 200, but problems arise when there's an HTTP error. I find it challenging to read the status code ...

What is the best way to create 2 select boxes that will disable each other if they match, and then automatically choose the second option so they do not match

Is there a way to have 2 select boxes automatically change one option to the second option on one box when they match? Instead of using an "alert", I am looking for a function that can automatically update one option in one of the select boxes if they mat ...

Passing Data to a Different Route in Vue.js

Being new to Vue.js, I have a question on how to efficiently handle data retrieval from my backend application. Here is the code snippet that fetches all the data: var app2 = new Vue({ delimiters: ['%%', '%%'], el: '#app2& ...

Utilizing State Variables Across Modules in ReactJS: A Guide

Having just started learning ReactJS, I am facing an issue with accessing the city_name variable in another module. Can anyone assist me with this problem? import { useState } from "react"; const SearchCity = (props) => { cons ...

UI and `setState` out of sync

Creating a website with forum-like features, where different forums are displayed using Next.js and include a pagination button for navigating to the next page. Current implementation involves querying data using getServerSideProps on initial page load, f ...

Using JQuery to append an additional column to an HTML table at the end, determined by array information

I've been experimenting with how to enhance an html table by adding a new column of data. The process involves clicking a button, extracting the existing data column in the table, storing it in an array, performing calculations on it, and then display ...

Trouble with JSON Credential Data Deserialization in C# while accessing the gcp auth file

After reading this particular question, I wanted to pose a related query to confirm an answer. Originally, my code was structured like this: string path2key = "C:/Users/me/Downloads/project-id-1-letters.json"; string jsonString = File.ReadAll ...