i tried a couple python json libraries. i used simplejson on the
server and was using cjson on the client, but i ran into this issue.
i'm now using simplejson on both sides, but i'm still interested in
this issue. did i do something wrong? is there a bug in one of the
libraries? or something i don't understand about the json spec?
i problem is the line where i call cjson.decode() below:
>>import simplejson import cjson
sj = simplejson.dump s('http://server.com') sj
'"http:\\/\\/server.com"'
>>cj = cjson.encode('h ttp://server.com') cj
'"http://server.com"'
>>simplejson.lo ads(cj)
u'http://server.com'
>>cjson.decode( cj)
'http://server.com'
>>simplejson.lo ads(sj)
u'http://server.com'
>>cjson.decode( sj)
'http:\\/\\/server.com' # is this correct????
is that last statement really correct?
thanks,
bryan 3 2353 be****@gmail.co m wrote:
i tried a couple python json libraries. i used simplejson on the
server and was using cjson on the client, but i ran into this issue.
i'm now using simplejson on both sides, but i'm still interested in
this issue. did i do something wrong? is there a bug in one of the
libraries? or something i don't understand about the json spec?
i problem is the line where i call cjson.decode() below:
>>>import simplejson import cjson
sj = simplejson.dump s('http://server.com') sj
'"http:\\/\\/server.com"'
>>>cj = cjson.encode('h ttp://server.com') cj
'"http://server.com"'
>>>simplejson.l oads(cj)
u'http://server.com'
>>>cjson.decode (cj)
'http://server.com'
>>>simplejson.l oads(sj)
u'http://server.com'
>>>cjson.decode (sj)
'http:\\/\\/server.com' # is this correct????
Known issue. See: http://blog.extracheese.org/2007/07/...isnt-json.html
Neither project has fixed it it seems. Not sure which is actually
the "correct" way to do it, but it would be nice if they would agree.
j
Joshua Kugler <jk*****@bigfoo t.comwrote:
be****@gmail.co m wrote:
>i tried a couple python json libraries. i used simplejson on the server and was using cjson on the client, but i ran into this issue. i'm now using simplejson on both sides, but i'm still interested in this issue. did i do something wrong? is there a bug in one of the libraries? or something i don't understand about the json spec?
i problem is the line where i call cjson.decode() below:
>>>>import simplejson import cjson > sj = simplejson.dump s('http://server.com') sj
'"http:\\/\\/server.com"'
>>>>cj = cjson.encode('h ttp://server.com') cj
'"http://server.com"'
>>>>simplejson. loads(cj)
u'http://server.com'
>>>>cjson.decod e(cj)
'http://server.com'
>>>>simplejson. loads(sj)
u'http://server.com'
>>>>cjson.decod e(sj)
'http:\\/\\/server.com' # is this correct????
Known issue. See: http://blog.extracheese.org/2007/07/...isnt-json.html
Neither project has fixed it it seems. Not sure which is actually
the "correct" way to do it, but it would be nice if they would agree.
Since both Opera and SpiderMonkey give http://server.com as result for
eval('"http:\\/\\/server.com"'), I'd say cjson gets it wrong (If by
nothing else than majority rule ;). That is unless I'm wrong that in
javascript something like eval(JSON_repr_ of_s) == s should be true.
Marc
Joshua Kugler <jk*****@bigfoo t.comwrote:
>Known issue. See: http://blog.extracheese.org/2007/07/...isnt-json.html
Neither project has fixed it it seems. Not sure which is actually the "correct" way to do it, but it would be nice if they would agree.
I think it's pretty clear (not just from that blog entry, but from
the grammar at http://json.org/) that cjson is incorrectly decoding
"\/". Whether it's sensible for simplejson to be encoding '/' as "\/"
is up for grabs, but it's perfectly correct for it to do so, so one
shouldn't expect it to be "fixed".
--
\S -- si***@chiark.gr eenend.org.uk -- http://www.chaos.org.uk/~sion/
"Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: G Matthew J |
last post by:
http://htmatters.net/htm/1/2005/07/evaling-JSON.cfm
This is more or less in response to Mr Crockford's admonition a few
months ago, "fork if you must". Ironically, although in that usenet
post he calls what I am suggesting "brittle", his own Javascript JSON
parser is not valid JSON, but rather conforms to my proposed variation
on JSON!! With an identifier prepended to the front of the JSON block,
and function literals as values: see...
|
by: Luke Matuszewski |
last post by:
Welcome
As suggested i looked into JSON project and was amazed but...
What about cyclical data structures - anybody was faced it in some
project ?
Is there any satisactional recomendation...
PS i am ready to use JSON as data/object interchange when using AJAX
and my J2EE project - because it is easier to traverse the JavaScript
object than its XML representation (so of course may argue).
|
by: Douglas Crockford |
last post by:
There is a new version of JSON.parse in JavaScript. It is vastly
faster and smaller than the previous version. It uses a single call to
eval to do the conversion, guarded by a single regexp test to assure
that it is safe.
JSON.parse = function (text) {
return
(/^(\s|]|"(\\|)*"|-?\d+(\.\d*)?(?\d+)?|true|false|null)+$/.test(text))
&& eval('(' + text + ')');
};
|
by: Kevin Newman |
last post by:
Hello,
I noticed that the JavaScript library for JSON posted on json.org
(http://www.json.org/json.js) is modifying Object.prototype (adding a
method - toJSONString). I thought this was considered bad practice
because it can disrupt the use of for in loops on Objects.
Am I incorrect?
Thanks,
|
by: Adam |
last post by:
I'm trying to retrieve some values from a json object, but instead it's
giving me the property name. For example:
var json = { "glossary": { "title": "example glossary" } };
console.log(json);
alert(json.glossary.title);
for (var x in json) { console.log(x); alert(x.title); }
This will show me the json object in the console with glossary and
title underneath it. When the alert for json.glossary.title fires, it
| |
by: ChrisO |
last post by:
I've been pretty infatuated with JSON for some time now since
"discovering" it a while back. (It's been there all along in
JavaScript, but it was just never "noticed" or used by most until
recently -- or maybe I should just speak for myself.)
The fact that JSON is more elegant goes without saying, yet I can't
seem to find a way to use JSON the way I *really* want to use it: to
create objects that can be instantated into multiple...
|
by: dhtmlkitchen |
last post by:
JSON
We all know what it is.
In ECMAScript 4, there's a JSON proposal:
Object.prototype.toJSONString
String.prototype.parseJSON
The current proposal, String.prototype.parseJSON, returns an object.
|
by: Jon Paal [MSMD] |
last post by:
using json like
( {"Records": , "RecordCount":"1" } )
and jquery like:
$.ajax({
....
success: function(json, status) {
|
by: Lasse Reichstein Nielsen |
last post by:
Max <adsl@tiscali.itwrites:
Not really. It shows that a particularly naïve implementation
of a conversion from XML to JSON doesn't work well.
What if the conversion of
<e>
some
|
by: crocodilu2008 |
last post by:
JSON vs. XML
JSON and XML are basically used for the same purpose—to represent and interchange data. I'll try to show you why you might want to use JSON rather than XML in an AJAX context by showing you an example of how an data class (actually, a list of PHP documentation pages) might be represented, first in XML. and then in JSON. This side-by-side comparison should let you begin to understand how to represent data in JSON. The XML version:...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |