“Expecting property name enclosed in double quotes” in json file












2















Here is the json file



{"pre_trigger": 4, "sampling frequency": 1652, "record length": 15.0, 
"sensors":
[{"model": "393B05", "serial": "46978", "sensitivity": 10030, "sensitivity_units": "mV/g", "sensor_type": "Accelerometer", "units": "g", "location": [7.01, -0.19, 0], "location_units": "m", "direction": [0, 0, 1], "trigger": true, "trigger_value": 0.005, "max_val": 0.45, "min_val": -0.45, "comments": "Inside B122 next to bookshelf", "channel": "cDAQ1Mod2/ai0"}],

[{"model": "393B05", "serial": "47085", "sensitivity": 9980, "sensitivity_units": "mV/g", "sensor_type": "Accelerometer", "units": "g", "location": [9.65, -0.19, 0], "location_units": "m", "direction": [0, 0, 1], "trigger": true, "trigger_value": 0.005, "max_val": 0.45, "min_val": -0.45, "comments": "Inside B122 under the whiteboard", "channel": "cDAQ1Mod2/ai1"}]

"parameters": {"general": , "specific": ["Walking direction", "Person ID"]}}


I'm not one to understand coding so I don't know where this error truly is coming from. I'm running a command the following commands



daq = DAQ()
daq.load_setup('json.fname')


Which returns the property error. There are no single quotes in the json file, so I truly don't know where the problem is. Below is where the error calls back to.



 def load_setup(self,fname='setup.json'):
"""
Opens the JSON file containing the setup parameters for the experiment.

Parameters
----------
fname : str
File that the parameters for the experiment were saved into (JSON file)

"""
import json

with open(fname, 'r') as setup_file:
setup_data = json.load(setup_file)

self.fs = setup_data['sampling frequency']
self.record_length = setup_data['record length']
self.sensors = setup_data['sensors']
self.parameters = setup_data['parameters']
self.pre_trigger = setup_data['pre_trigger']









share|improve this question

























  • There aren't sufficient information so we can try your code case and understand problem. Can you add more codes, like that of the class and explain better what you are trying of achieving with the two lines. However let me try guessing, I think you are accessing a property that there isn't on json object if you function executes with exec() the passed string.

    – Iulian
    Nov 21 '18 at 16:44













  • Yes I will try. I'll add where the error calls back to above.

    – newtothis
    Nov 21 '18 at 16:52


















2















Here is the json file



{"pre_trigger": 4, "sampling frequency": 1652, "record length": 15.0, 
"sensors":
[{"model": "393B05", "serial": "46978", "sensitivity": 10030, "sensitivity_units": "mV/g", "sensor_type": "Accelerometer", "units": "g", "location": [7.01, -0.19, 0], "location_units": "m", "direction": [0, 0, 1], "trigger": true, "trigger_value": 0.005, "max_val": 0.45, "min_val": -0.45, "comments": "Inside B122 next to bookshelf", "channel": "cDAQ1Mod2/ai0"}],

[{"model": "393B05", "serial": "47085", "sensitivity": 9980, "sensitivity_units": "mV/g", "sensor_type": "Accelerometer", "units": "g", "location": [9.65, -0.19, 0], "location_units": "m", "direction": [0, 0, 1], "trigger": true, "trigger_value": 0.005, "max_val": 0.45, "min_val": -0.45, "comments": "Inside B122 under the whiteboard", "channel": "cDAQ1Mod2/ai1"}]

"parameters": {"general": , "specific": ["Walking direction", "Person ID"]}}


I'm not one to understand coding so I don't know where this error truly is coming from. I'm running a command the following commands



daq = DAQ()
daq.load_setup('json.fname')


Which returns the property error. There are no single quotes in the json file, so I truly don't know where the problem is. Below is where the error calls back to.



 def load_setup(self,fname='setup.json'):
"""
Opens the JSON file containing the setup parameters for the experiment.

Parameters
----------
fname : str
File that the parameters for the experiment were saved into (JSON file)

"""
import json

with open(fname, 'r') as setup_file:
setup_data = json.load(setup_file)

self.fs = setup_data['sampling frequency']
self.record_length = setup_data['record length']
self.sensors = setup_data['sensors']
self.parameters = setup_data['parameters']
self.pre_trigger = setup_data['pre_trigger']









share|improve this question

























  • There aren't sufficient information so we can try your code case and understand problem. Can you add more codes, like that of the class and explain better what you are trying of achieving with the two lines. However let me try guessing, I think you are accessing a property that there isn't on json object if you function executes with exec() the passed string.

    – Iulian
    Nov 21 '18 at 16:44













  • Yes I will try. I'll add where the error calls back to above.

    – newtothis
    Nov 21 '18 at 16:52
















2












2








2








Here is the json file



{"pre_trigger": 4, "sampling frequency": 1652, "record length": 15.0, 
"sensors":
[{"model": "393B05", "serial": "46978", "sensitivity": 10030, "sensitivity_units": "mV/g", "sensor_type": "Accelerometer", "units": "g", "location": [7.01, -0.19, 0], "location_units": "m", "direction": [0, 0, 1], "trigger": true, "trigger_value": 0.005, "max_val": 0.45, "min_val": -0.45, "comments": "Inside B122 next to bookshelf", "channel": "cDAQ1Mod2/ai0"}],

[{"model": "393B05", "serial": "47085", "sensitivity": 9980, "sensitivity_units": "mV/g", "sensor_type": "Accelerometer", "units": "g", "location": [9.65, -0.19, 0], "location_units": "m", "direction": [0, 0, 1], "trigger": true, "trigger_value": 0.005, "max_val": 0.45, "min_val": -0.45, "comments": "Inside B122 under the whiteboard", "channel": "cDAQ1Mod2/ai1"}]

"parameters": {"general": , "specific": ["Walking direction", "Person ID"]}}


I'm not one to understand coding so I don't know where this error truly is coming from. I'm running a command the following commands



daq = DAQ()
daq.load_setup('json.fname')


Which returns the property error. There are no single quotes in the json file, so I truly don't know where the problem is. Below is where the error calls back to.



 def load_setup(self,fname='setup.json'):
"""
Opens the JSON file containing the setup parameters for the experiment.

Parameters
----------
fname : str
File that the parameters for the experiment were saved into (JSON file)

"""
import json

with open(fname, 'r') as setup_file:
setup_data = json.load(setup_file)

self.fs = setup_data['sampling frequency']
self.record_length = setup_data['record length']
self.sensors = setup_data['sensors']
self.parameters = setup_data['parameters']
self.pre_trigger = setup_data['pre_trigger']









share|improve this question
















Here is the json file



{"pre_trigger": 4, "sampling frequency": 1652, "record length": 15.0, 
"sensors":
[{"model": "393B05", "serial": "46978", "sensitivity": 10030, "sensitivity_units": "mV/g", "sensor_type": "Accelerometer", "units": "g", "location": [7.01, -0.19, 0], "location_units": "m", "direction": [0, 0, 1], "trigger": true, "trigger_value": 0.005, "max_val": 0.45, "min_val": -0.45, "comments": "Inside B122 next to bookshelf", "channel": "cDAQ1Mod2/ai0"}],

[{"model": "393B05", "serial": "47085", "sensitivity": 9980, "sensitivity_units": "mV/g", "sensor_type": "Accelerometer", "units": "g", "location": [9.65, -0.19, 0], "location_units": "m", "direction": [0, 0, 1], "trigger": true, "trigger_value": 0.005, "max_val": 0.45, "min_val": -0.45, "comments": "Inside B122 under the whiteboard", "channel": "cDAQ1Mod2/ai1"}]

"parameters": {"general": , "specific": ["Walking direction", "Person ID"]}}


I'm not one to understand coding so I don't know where this error truly is coming from. I'm running a command the following commands



daq = DAQ()
daq.load_setup('json.fname')


Which returns the property error. There are no single quotes in the json file, so I truly don't know where the problem is. Below is where the error calls back to.



 def load_setup(self,fname='setup.json'):
"""
Opens the JSON file containing the setup parameters for the experiment.

Parameters
----------
fname : str
File that the parameters for the experiment were saved into (JSON file)

"""
import json

with open(fname, 'r') as setup_file:
setup_data = json.load(setup_file)

self.fs = setup_data['sampling frequency']
self.record_length = setup_data['record length']
self.sensors = setup_data['sensors']
self.parameters = setup_data['parameters']
self.pre_trigger = setup_data['pre_trigger']






python json quotes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 16:53







newtothis

















asked Nov 21 '18 at 16:17









newtothisnewtothis

186




186













  • There aren't sufficient information so we can try your code case and understand problem. Can you add more codes, like that of the class and explain better what you are trying of achieving with the two lines. However let me try guessing, I think you are accessing a property that there isn't on json object if you function executes with exec() the passed string.

    – Iulian
    Nov 21 '18 at 16:44













  • Yes I will try. I'll add where the error calls back to above.

    – newtothis
    Nov 21 '18 at 16:52





















  • There aren't sufficient information so we can try your code case and understand problem. Can you add more codes, like that of the class and explain better what you are trying of achieving with the two lines. However let me try guessing, I think you are accessing a property that there isn't on json object if you function executes with exec() the passed string.

    – Iulian
    Nov 21 '18 at 16:44













  • Yes I will try. I'll add where the error calls back to above.

    – newtothis
    Nov 21 '18 at 16:52



















There aren't sufficient information so we can try your code case and understand problem. Can you add more codes, like that of the class and explain better what you are trying of achieving with the two lines. However let me try guessing, I think you are accessing a property that there isn't on json object if you function executes with exec() the passed string.

– Iulian
Nov 21 '18 at 16:44







There aren't sufficient information so we can try your code case and understand problem. Can you add more codes, like that of the class and explain better what you are trying of achieving with the two lines. However let me try guessing, I think you are accessing a property that there isn't on json object if you function executes with exec() the passed string.

– Iulian
Nov 21 '18 at 16:44















Yes I will try. I'll add where the error calls back to above.

– newtothis
Nov 21 '18 at 16:52







Yes I will try. I'll add where the error calls back to above.

– newtothis
Nov 21 '18 at 16:52














1 Answer
1






active

oldest

votes


















1














You simply do not have valid JSON (there isn't anything wrong with your Python code). You're not using the array functionality correctly. A JSON array looks like this:



{"some_array": ["first item", "second item", ..., "last item"]}


it does not look like this (which is what you had and why you get the error you're getting):



{"some_array": ["first item"], ["second item"], ..., ["last item"]}


Long story short, your list items are comma delimted inside the square brackets. Here's what your JSON should look like (sensor array fixed, and pretty-printed):



{
"pre_trigger": 4,
"sampling frequency": 1652,
"record length": 15.0,
"sensors":
[
{
"model": "393B05",
"serial": "46978",
"sensitivity": 10030,
"sensitivity_units": "mV/g",
"sensor_type": "Accelerometer",
"units": "g",
"location": [7.01, -0.19, 0],
"location_units": "m",
"direction": [0, 0, 1],
"trigger": true,
"trigger_value": 0.005,
"max_val": 0.45,
"min_val": -0.45,
"comments": "Inside B122 next to bookshelf",
"channel": "cDAQ1Mod2/ai0"
},
{
"model": "393B05",
"serial": "47085",
"sensitivity": 9980,
"sensitivity_units": "mV/g",
"sensor_type": "Accelerometer",
"units": "g",
"location": [9.65, -0.19, 0],
"location_units": "m",
"direction": [0, 0, 1],
"trigger": true,
"trigger_value": 0.005,
"max_val": 0.45,
"min_val": -0.45,
"comments": "Inside B122 under the whiteboard",
"channel": "cDAQ1Mod2/ai1"
}
],

"parameters": {
"general": ,
"specific":
[
"Walking direction",
"Person ID"
]
}
}


I recommend always keeping your JSON pretty-printed (even on disk), as it makes it easier to read/understand. Part of the appeal of the JSON format is that you can easily eyeball it as a human.



The rest of your code that you posted worked fine after this fix.



HTH.






share|improve this answer
























  • Sorry for the late reply, but this worked! Thank you so much.

    – newtothis
    Nov 28 '18 at 1:37











  • @newtothis Glad to have helped! If it's the right answer, you can also accept it (checkmark next to where you've upvoted).

    – Matt Messersmith
    Nov 28 '18 at 1:39











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416320%2fexpecting-property-name-enclosed-in-double-quotes-in-json-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You simply do not have valid JSON (there isn't anything wrong with your Python code). You're not using the array functionality correctly. A JSON array looks like this:



{"some_array": ["first item", "second item", ..., "last item"]}


it does not look like this (which is what you had and why you get the error you're getting):



{"some_array": ["first item"], ["second item"], ..., ["last item"]}


Long story short, your list items are comma delimted inside the square brackets. Here's what your JSON should look like (sensor array fixed, and pretty-printed):



{
"pre_trigger": 4,
"sampling frequency": 1652,
"record length": 15.0,
"sensors":
[
{
"model": "393B05",
"serial": "46978",
"sensitivity": 10030,
"sensitivity_units": "mV/g",
"sensor_type": "Accelerometer",
"units": "g",
"location": [7.01, -0.19, 0],
"location_units": "m",
"direction": [0, 0, 1],
"trigger": true,
"trigger_value": 0.005,
"max_val": 0.45,
"min_val": -0.45,
"comments": "Inside B122 next to bookshelf",
"channel": "cDAQ1Mod2/ai0"
},
{
"model": "393B05",
"serial": "47085",
"sensitivity": 9980,
"sensitivity_units": "mV/g",
"sensor_type": "Accelerometer",
"units": "g",
"location": [9.65, -0.19, 0],
"location_units": "m",
"direction": [0, 0, 1],
"trigger": true,
"trigger_value": 0.005,
"max_val": 0.45,
"min_val": -0.45,
"comments": "Inside B122 under the whiteboard",
"channel": "cDAQ1Mod2/ai1"
}
],

"parameters": {
"general": ,
"specific":
[
"Walking direction",
"Person ID"
]
}
}


I recommend always keeping your JSON pretty-printed (even on disk), as it makes it easier to read/understand. Part of the appeal of the JSON format is that you can easily eyeball it as a human.



The rest of your code that you posted worked fine after this fix.



HTH.






share|improve this answer
























  • Sorry for the late reply, but this worked! Thank you so much.

    – newtothis
    Nov 28 '18 at 1:37











  • @newtothis Glad to have helped! If it's the right answer, you can also accept it (checkmark next to where you've upvoted).

    – Matt Messersmith
    Nov 28 '18 at 1:39
















1














You simply do not have valid JSON (there isn't anything wrong with your Python code). You're not using the array functionality correctly. A JSON array looks like this:



{"some_array": ["first item", "second item", ..., "last item"]}


it does not look like this (which is what you had and why you get the error you're getting):



{"some_array": ["first item"], ["second item"], ..., ["last item"]}


Long story short, your list items are comma delimted inside the square brackets. Here's what your JSON should look like (sensor array fixed, and pretty-printed):



{
"pre_trigger": 4,
"sampling frequency": 1652,
"record length": 15.0,
"sensors":
[
{
"model": "393B05",
"serial": "46978",
"sensitivity": 10030,
"sensitivity_units": "mV/g",
"sensor_type": "Accelerometer",
"units": "g",
"location": [7.01, -0.19, 0],
"location_units": "m",
"direction": [0, 0, 1],
"trigger": true,
"trigger_value": 0.005,
"max_val": 0.45,
"min_val": -0.45,
"comments": "Inside B122 next to bookshelf",
"channel": "cDAQ1Mod2/ai0"
},
{
"model": "393B05",
"serial": "47085",
"sensitivity": 9980,
"sensitivity_units": "mV/g",
"sensor_type": "Accelerometer",
"units": "g",
"location": [9.65, -0.19, 0],
"location_units": "m",
"direction": [0, 0, 1],
"trigger": true,
"trigger_value": 0.005,
"max_val": 0.45,
"min_val": -0.45,
"comments": "Inside B122 under the whiteboard",
"channel": "cDAQ1Mod2/ai1"
}
],

"parameters": {
"general": ,
"specific":
[
"Walking direction",
"Person ID"
]
}
}


I recommend always keeping your JSON pretty-printed (even on disk), as it makes it easier to read/understand. Part of the appeal of the JSON format is that you can easily eyeball it as a human.



The rest of your code that you posted worked fine after this fix.



HTH.






share|improve this answer
























  • Sorry for the late reply, but this worked! Thank you so much.

    – newtothis
    Nov 28 '18 at 1:37











  • @newtothis Glad to have helped! If it's the right answer, you can also accept it (checkmark next to where you've upvoted).

    – Matt Messersmith
    Nov 28 '18 at 1:39














1












1








1







You simply do not have valid JSON (there isn't anything wrong with your Python code). You're not using the array functionality correctly. A JSON array looks like this:



{"some_array": ["first item", "second item", ..., "last item"]}


it does not look like this (which is what you had and why you get the error you're getting):



{"some_array": ["first item"], ["second item"], ..., ["last item"]}


Long story short, your list items are comma delimted inside the square brackets. Here's what your JSON should look like (sensor array fixed, and pretty-printed):



{
"pre_trigger": 4,
"sampling frequency": 1652,
"record length": 15.0,
"sensors":
[
{
"model": "393B05",
"serial": "46978",
"sensitivity": 10030,
"sensitivity_units": "mV/g",
"sensor_type": "Accelerometer",
"units": "g",
"location": [7.01, -0.19, 0],
"location_units": "m",
"direction": [0, 0, 1],
"trigger": true,
"trigger_value": 0.005,
"max_val": 0.45,
"min_val": -0.45,
"comments": "Inside B122 next to bookshelf",
"channel": "cDAQ1Mod2/ai0"
},
{
"model": "393B05",
"serial": "47085",
"sensitivity": 9980,
"sensitivity_units": "mV/g",
"sensor_type": "Accelerometer",
"units": "g",
"location": [9.65, -0.19, 0],
"location_units": "m",
"direction": [0, 0, 1],
"trigger": true,
"trigger_value": 0.005,
"max_val": 0.45,
"min_val": -0.45,
"comments": "Inside B122 under the whiteboard",
"channel": "cDAQ1Mod2/ai1"
}
],

"parameters": {
"general": ,
"specific":
[
"Walking direction",
"Person ID"
]
}
}


I recommend always keeping your JSON pretty-printed (even on disk), as it makes it easier to read/understand. Part of the appeal of the JSON format is that you can easily eyeball it as a human.



The rest of your code that you posted worked fine after this fix.



HTH.






share|improve this answer













You simply do not have valid JSON (there isn't anything wrong with your Python code). You're not using the array functionality correctly. A JSON array looks like this:



{"some_array": ["first item", "second item", ..., "last item"]}


it does not look like this (which is what you had and why you get the error you're getting):



{"some_array": ["first item"], ["second item"], ..., ["last item"]}


Long story short, your list items are comma delimted inside the square brackets. Here's what your JSON should look like (sensor array fixed, and pretty-printed):



{
"pre_trigger": 4,
"sampling frequency": 1652,
"record length": 15.0,
"sensors":
[
{
"model": "393B05",
"serial": "46978",
"sensitivity": 10030,
"sensitivity_units": "mV/g",
"sensor_type": "Accelerometer",
"units": "g",
"location": [7.01, -0.19, 0],
"location_units": "m",
"direction": [0, 0, 1],
"trigger": true,
"trigger_value": 0.005,
"max_val": 0.45,
"min_val": -0.45,
"comments": "Inside B122 next to bookshelf",
"channel": "cDAQ1Mod2/ai0"
},
{
"model": "393B05",
"serial": "47085",
"sensitivity": 9980,
"sensitivity_units": "mV/g",
"sensor_type": "Accelerometer",
"units": "g",
"location": [9.65, -0.19, 0],
"location_units": "m",
"direction": [0, 0, 1],
"trigger": true,
"trigger_value": 0.005,
"max_val": 0.45,
"min_val": -0.45,
"comments": "Inside B122 under the whiteboard",
"channel": "cDAQ1Mod2/ai1"
}
],

"parameters": {
"general": ,
"specific":
[
"Walking direction",
"Person ID"
]
}
}


I recommend always keeping your JSON pretty-printed (even on disk), as it makes it easier to read/understand. Part of the appeal of the JSON format is that you can easily eyeball it as a human.



The rest of your code that you posted worked fine after this fix.



HTH.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 '18 at 17:46









Matt MessersmithMatt Messersmith

6,24921832




6,24921832













  • Sorry for the late reply, but this worked! Thank you so much.

    – newtothis
    Nov 28 '18 at 1:37











  • @newtothis Glad to have helped! If it's the right answer, you can also accept it (checkmark next to where you've upvoted).

    – Matt Messersmith
    Nov 28 '18 at 1:39



















  • Sorry for the late reply, but this worked! Thank you so much.

    – newtothis
    Nov 28 '18 at 1:37











  • @newtothis Glad to have helped! If it's the right answer, you can also accept it (checkmark next to where you've upvoted).

    – Matt Messersmith
    Nov 28 '18 at 1:39

















Sorry for the late reply, but this worked! Thank you so much.

– newtothis
Nov 28 '18 at 1:37





Sorry for the late reply, but this worked! Thank you so much.

– newtothis
Nov 28 '18 at 1:37













@newtothis Glad to have helped! If it's the right answer, you can also accept it (checkmark next to where you've upvoted).

– Matt Messersmith
Nov 28 '18 at 1:39





@newtothis Glad to have helped! If it's the right answer, you can also accept it (checkmark next to where you've upvoted).

– Matt Messersmith
Nov 28 '18 at 1:39




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416320%2fexpecting-property-name-enclosed-in-double-quotes-in-json-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini