Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72072
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <gheskett@shentel.net> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'third- party': 0.04; 'output': 0.05; 'json': 0.07; 'linux,': 0.07; 'converted': 0.09; 'exit': 0.09; 'received:localnet': 0.09; 'python': 0.11; '127': 0.16; '255': 0.16; 'command-line': 0.16; 'grounds': 0.16; 'guys,': 0.16; 'parse,': 0.16; 'patches': 0.16; 'roy': 0.16; 'soap,': 0.16; 'wrote:': 0.18; 'module': 0.19; 'file,': 0.19; 'result.': 0.19; 'solution.': 0.20; 'shell': 0.22; 'format,': 0.24; 'parse': 0.24; 'string,': 0.24; 'cheers,': 0.24; 'source': 0.25; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'on,': 0.29; 'xml': 0.29; "i'm": 0.30; 'bunch': 0.31; 'faster,': 0.31; 'run': 0.32; 'checking': 0.33; 'url:non-standard http port': 0.33; 'core': 0.34; 'received:209.85': 0.35; 'case,': 0.35; 'done.': 0.35; 'monday': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'module.': 0.36; 'object,': 0.36; 'ubuntu': 0.36; "didn't": 0.36; 'example,': 0.37; 'operating': 0.37; 'received:209.85.216': 0.37; 'received:209': 0.37; 'system,': 0.38; 'same.': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'bad': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'numbers': 0.61; "you're": 0.61; 'first': 0.61; 'header:Message-Id:1': 0.63; 'email addr:gmail.com': 0.63; 'charset:windows-1256': 0.64; 'mar': 0.68; 'reads': 0.68; 'smith': 0.68; 'store,': 0.68; 'received:204': 0.75; 'article': 0.77; 'old,': 0.85; 'boxes': 0.91 |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; bh=eG9ARJKPZ5k6mx6WciOzVPBbY7XBKe0XpEmx2xgGix4=; b=CEQll8wwlpp+G2aPlT3e9sIlkpJcuDVMCr09+cVz6cpIcqsTjj+HlCwjF1s8l19shb k7rlA7gK6yoR9PW4+jQPwAxt7RI/YugD2bVmETA0oWDLV8pat0E4dRfJ4YLoBzOU0lse pFasVwbXgXCrCIm+xrwccRq86qoCTcj0SbNq94HZSV9evvIpyYf+DwPxdY7iesA2NV1F IyzFGAsscpUVN/iMaTQ6jvArDhNCcupeOgU4VzX5E/sYq5roYbYaMhzi5AvLrza4qGoO QRMc2/7GyCwoggNyoo0nAcYIE4gdGrn5q3W57kdZ+17pyKdOUSInUo3bNROGVR+Vz6fj jSdw== |
| X-Gm-Message-State | ALoCoQllQZbL7G3NMR7lnpR2fHi2ljjjO6bWHLas/Ol+HabWq9V6CL6eWjrwC4GGt1XvhWWi1opX |
| X-Received | by 10.224.166.9 with SMTP id k9mr33229134qay.25.1401118632532; Mon, 26 May 2014 08:37:12 -0700 (PDT) |
| From | Gene Heskett <gheskett@shentel.net> |
| X-Google-Original-From | Gene Heskett <gheskett@wdtv.com> |
| To | python-list@python.org |
| Subject | Re: Verify JSON Data |
| Date | Mon, 26 May 2014 11:37:10 -0400 |
| References | <e26d3f14-ac97-4abd-bdfc-699d9ed2175c@googlegroups.com> <roy-CA8FC6.11195326052014@news.panix.com> |
| In-Reply-To | <roy-CA8FC6.11195326052014@news.panix.com> |
| MIME-Version | 1.0 |
| Content-Type | Text/Plain; charset="windows-1256" |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10347.1401119046.18130.python-list@python.org> (permalink) |
| Lines | 61 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1401119046 news.xs4all.nl 2841 [2001:888:2000:d::a6]:57429 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:72072 |
Show key headers only | View raw
On Monday 26 May 2014 11:19:53 Roy Smith did opine And Gene did reply: > In article <e26d3f14-ac97-4abd-bdfc-699d9ed2175c@googlegroups.com>, > > gaurangnshah@gmail.com wrote: > > Hi Guys, > > > > Would someone let me know how to verify JSON data in python. There > > are so many modules available to verify XML file, however i didn't > > find any good module to verify JSON Data. > > Python comes with a built-in json module. Just use json.load() or > json.loads() to parse your JSON data. The first call reads from a > string, the second on from a file, but in all other ways, they're > identical. > > There are a bunch of third-party modules (ujson, etc) which are faster, > but fundamentally, they're all the same. > > If I understand you correctly, you're reading a JSON document which is > so large that if you store the converted data as a Python object, you > run out of memory? If that's the case, I'm not sure if there's a good > pure Python solution. I don't know of any json modules which parse, > but don't store, the data. > > Depending on what operating system you're on, there may be a > command-line utility which parse JSON. For example, on Ubuntu linux, > there's "json_xs". Perhaps shell out to that, use the "-t null" output > format, redirect the output to /dev/null, and see what exit status you > get: > > # Good JSON > $ echo '[1, 2, 3]' | json_xs -t null 2>/dev/null; echo $? > 0 > > # Bad JSON > $ echo '[1; 2, 3]' | json_xs -t null 2>/dev/null; echo $? > 255 > > Wrap this up in a subprocess.check_output() call, and you're done. Just for S&G, and without checking the version numbers of anything, this may not be all that bulletproof a test: gene@coyote:~$ echo '[1, 2, 3]' | json_xs -t null 2>/dev/null; echo $? 127 gene@coyote:~$ echo '[1; 2, 3]' | json_xs -t null 2>/dev/null; echo $? 127 Old, buntu 10.04.4 LTS system, all up to date security patches wise. kernal 3.13.9, PAE on a quad core phenom. Interesting result. Source of error? DamnedifIknow. Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page <http://geneslinuxbox.net:6309/gene> US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Verify JSON Data gaurangnshah@gmail.com - 2014-05-26 07:26 -0700
Re: Verify JSON Data Roy Smith <roy@panix.com> - 2014-05-26 11:19 -0400
Re: Verify JSON Data Gene Heskett <gheskett@shentel.net> - 2014-05-26 11:37 -0400
Re: Verify JSON Data Roy Smith <roy@panix.com> - 2014-05-26 11:55 -0400
Re: Verify JSON Data Chris Angelico <rosuav@gmail.com> - 2014-05-27 02:02 +1000
Re: Verify JSON Data Gene Heskett <gheskett@shentel.net> - 2014-05-26 12:43 -0400
Re: Verify JSON Data Chris Angelico <rosuav@gmail.com> - 2014-05-27 01:58 +1000
Re: Verify JSON Data Chris Angelico <rosuav@gmail.com> - 2014-05-27 02:00 +1000
Re: Verify JSON Data Burak Arslan <burak.arslan@arskom.com.tr> - 2014-05-26 17:28 +0200
Re: Verify JSON Data Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-26 15:43 +0000
Re: Verify JSON Data Gene Heskett <gheskett@shentel.net> - 2014-05-26 12:44 -0400
Re: Verify JSON Data Grant Edwards <invalid@invalid.invalid> - 2014-05-26 18:35 +0000
Re: Verify JSON Data Rustom Mody <rustompmody@gmail.com> - 2014-05-26 21:28 -0700
csiph-web