LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-02-2022, 11:10 AM   #16
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,610

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553

Quote:
Originally Posted by sundialsvcs View Post
What I am specifically saying is that you should treat the JSON data "as a blob." Don't try to "format it" – it doesn't need to be pretty – and don't try to write it yourself.
JSON is specifically intended to be readable and writable by humans.

If one were to ignore that feature, using it wouldn't make sense, since there are numerous better formats available.

 
Old 07-02-2022, 11:36 PM   #17
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,235

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by boughtonp View Post
JSON is specifically intended to be readable and writable by humans.

If one were to ignore that feature, using it wouldn't make sense, since there are numerous better formats available.
Well, yes, that is extremely correct, but Sundial's point about not trying to write JSON by hand does apply here.
 
Old 07-03-2022, 06:02 AM   #18
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,868
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Though if it were the case, there would be a way to add single- and/or multi-line comments in Json.
 
Old 07-03-2022, 07:41 AM   #19
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,610

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
Quote:
Originally Posted by dugan View Post
Well, yes, that is extremely correct, but Sundial's point about not trying to write JSON by hand does apply here.
In what way?

It looks like a configuration file to me, and the invalid syntax in post #1 is likely due to manually truncating a longer file in order to post here.

If the real file were syntactically invalid a JSONDecodeError would be raised, but there's no evidence of that having happened - the issue appears to be exclusively about understanding how to access nested elements.

 
1 members found this post helpful.
  


Reply

Tags
json, json jq, python



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Parsing JSON Data in Python LXer Syndicated Linux News 0 06-23-2020 12:25 AM
[SOLVED] Parsing JSON like string in Python Mark_667 Programming 2 11-09-2018 10:40 AM
[SOLVED] Parsing Json with Python slimcharles Programming 6 03-17-2017 09:04 AM
[SOLVED] Parsing Javascript To JSON Using Python 3 cin_ Programming 3 05-18-2015 04:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration