Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

json · JSON JavaScript Object Notation

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 590
  • Category: Data Formats
  • Founded: Jul 19, 2005
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Messages

Advanced
Messages Help
Messages 88 - 123 of 1953   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#88 From: Martin Cooper <mfncooper@...>
Date: Sat Aug 20, 2005 5:11 am
Subject: Re: Re: Comments
mfncooper
Send Email Send Email
 
On 8/17/05, Douglas Crockford <douglas@...> wrote:
> --- In json@yahoogroups.com, "patrickdlogan" <patrickdlogan@s...> wrote:
> > > Comments are being removed from JSON.
> >
> > Good enough. I'll take the code out of json-py soon.
>
> If you like. There is no harm in leaving it in. The current Java
> decoder recognizes comments in the slashslash, slashstar, and hash
> forms. I am leaving it in because there is no need to take it out, and
> it might be useful.

I would think that the fact that a parse is successful no longer means
that the input was valid JSON would be a pretty good reason to take it
out...

--
Martin Cooper


>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>

#89 From: "TCQ" <despam2004@...>
Date: Sat Aug 20, 2005 4:22 pm
Subject: JSON as a function parameter
despam2004
Send Email Send Email
 
Greetings fellow JSON Lovers.

I have been spending building a great deal of complex Product/Business
workflow wizards and tools that are required to handle tons of data
and great deal of client side functionality.

As a result, many functions and methods have gotten to require longer
and longer set of parameters. The worst case yet is about 12
parameters with some being optional. In these cases, the calling code
gets more and more un-readable as you add args. Also optional entries
must have null ("") values all over the place making for unneeded code.

With my ultimate goal of having clean and maintainable code, I have
started using using json to pass the parameters and data to the
function/method.

before:
. obj.init(
. . "My Type","My Name","n",true, false...
. )

after:
. obj.init({
. . type: "My Type", name: "My Name", rev: "n", doThis: true, doThat:
false...
. })

Has anybody conducted or seen tests on the performance of this json
method vs regular calls.

[Notes]

[Advantages]
. Cleaner calling code
. Flexible calling API
. Somewhat cleaner callee code from visually implied namespace (j.arg1)
. Tightened API calls:
. . obj.myMethod = function Obj_myMethod(j){// (singleton)
. . . . if(!isJSON(j)){debugErr("j must be a JSON")}
. . }
. JSON variable can be easily passed around

[Disadvantages]
. Overall size of the calling code is a little larger
. Hit on interpreter performance to parse json
. Null value parameter assertions require additional code

.:JsD:.

(dupe post from comp.lang.javascript ... just discovered json group
today :)

#90 From: Ronny Hanssen <ronnyh@...>
Date: Sat Aug 20, 2005 4:50 pm
Subject: Re: JSON as a function parameter
ronnyh1969
Send Email Send Email
 
In general my experience on this matter is only positive. I've had *no*
negative effects or side effects whatsoever.

Specific comments inlined below.

TCQ wrote:
(...snip...)
> [Notes]
>
> [Advantages]
> . Cleaner calling code
> . Flexible calling API
> . Somewhat cleaner callee code from visually implied namespace (j.arg1)
> . Tightened API calls:
> . . obj.myMethod = function Obj_myMethod(j){// (singleton)
> . . . . if(!isJSON(j)){debugErr("j must be a JSON")}
> . . }
> . JSON variable can be easily passed around

I'd like to add how easy it is to have backwards compatibility when
upgrading the API. (Maybe that's what you meant with the flexible
calling API? I interpreted that to be the advantage to mix the order as
you like.
Also - this might be personal preference only, but I like the way the
calls are self-explanatory, instead of wondering what the third or
fourth integer argument is actually doing.

>
> [Disadvantages]
> . Overall size of the calling code is a little larger
> . Hit on interpreter performance to parse json

You are talking about code in a javascript interpreter/engine, right?
Because then you'd have *no* extra JSON parsing. JSON *is* javascript,
and what actually happens is that an object is created to hold your
arguments. And this object creation is the extra fingerprint. This might
be what you mean, I just wanted to be clear that we are not talking
about JSON parsing, we are talking about creating a javascript native
object. However, I've seen no comparisons on these two different ways of
passing arguments. That would be easy though. Any parameters added - be
it a string, a number, bool or whatever - will take time to get their
own memory slot assigned anyhow. The last part is the creation of the
container-object, and possible any differences in memory allocation
depending on whether the args are local or a part of an object (might be
some other situations. Someone more into the details of the javascript
engine might be able to shed light on that.

> . Null value parameter assertions require additional code

I am not sure what you are referring to. Is it the fact that you in the
function declared cannot use an arg.property, unless it has explicitly
been given a value? In the later versions of javascript all you need to
do is:
   if (arg.myprop) [action]

which is exactly the same code you could use if it was indeed null. So
there's no difference there. However. If you are using nested JSON
structures, with subobjects, the above test is not good enough. If you
have arg.myobj.myprop, then if the arg doesn't pass arg.myobj then you
cannot test arg.myobject.myprop, then you have to something like this:
   if (arg.myobj && arg.myobj.myprop) [action]

DISCLAIMER: It's about 6 months since I last programmed any JS, so there
might be some issues regarding the techniques above. Don't expect all
samples to work without correction :)

Regards,
------------------------------------------------------------------------
/*Ronny Hanssen*/

#91 From: Michal Migurski <mike-jsonphp@...>
Date: Sat Aug 20, 2005 7:12 pm
Subject: Re: JSON as a function parameter
michal_migurski
Send Email Send Email
 
> [Advantages]
> . Cleaner calling code
> . Flexible calling API
> . Somewhat cleaner callee code from visually implied namespace
> (j.arg1)
> . Tightened API calls:
> . . obj.myMethod = function Obj_myMethod(j){// (singleton)
> . . . . if(!isJSON(j)){debugErr("j must be a JSON")}
> . . }
> . JSON variable can be easily passed around
>
> [Disadvantages]
> . Overall size of the calling code is a little larger
> . Hit on interpreter performance to parse json
> . Null value parameter assertions require additional code

I use this method in my PHP work pretty often, especially when
consuming GET or POST vars, or instantiating objects which have a mix
of required and optional arguments. Some languages have explicit
support for this sort of use, such as Python:

      def f(**kwargs):
          print kwargs['msg']

      # prints "hello world"
      f(msg='hello world')

Ronny is right - there is no JSON parsing overhead in what you're
doing, because you are passing plain old javascript object literals.
http://developer.mozilla.org/en/docs/
Core_JavaScript_1.5_Guide:Literals#Object_Literals

------------------------------------------------------
michal migurski- contact info, blog, and pgp key:
sf/ca            http://mike.teczno.com/contact.html

#92 From: "George" <georgenava@...>
Date: Sun Aug 21, 2005 3:23 am
Subject: Re: JSON as a function parameter
georgenava
Send Email Send Email
 
That is valid javascript code, as pointed out already, object literals.

You can also create the object first, then pass it to the method:

args = {type:"My Type", name:null, rev:3, doThis:true};
obj.init(args);


--- In json@yahoogroups.com, "TCQ" <despam2004@y...> wrote:
>
> before:
> . obj.init(
> . . "My Type","My Name","n",true, false...
> . )
>
> after:
> . obj.init({
> . . type: "My Type", name: "My Name", rev: "n", doThis: true, doThat:
> false...
> . })
>

#93 From: Michael Schwarz <michael.schwarz@...>
Date: Tue Aug 23, 2005 6:22 am
Subject: JSON C# Parser
schwarz_inte...
Send Email Send Email
 
Hello,

I will first introduce myself: I'm the author of the Ajax.NET
(http://ajax.schwarz-interactive.de/ or
http://weblogs.asp.net/mschwarz/) and using JSON to transport objects
from server-side .NET code to JavaScript.

Currently I'm working on a parser (or converter) that will create .NET
objects on the server-side from a JSON string. I had a look at the
JSON parser at http://www.json.org/ but ran into different problems.
Has anyone developed such a parser already or is working on it?

CIAO
Michael

#94 From: "schwarz_interactive" <michael.schwarz@...>
Date: Tue Aug 23, 2005 6:27 am
Subject: Re: AJAJ?
schwarz_inte...
Send Email Send Email
 
--- In json@yahoogroups.com, "Dale" <code_ronin@y...> wrote:
> Anyone using JSON as a replacement for XML in an AJAX-like project?


Yes, I do, have a look at http://ajax.schwarz-interactive.de/.

CIAO
Michael



>
> A couple of years ago I used dynamic <script> elements to
communicate
> asynchronously with the server-side, but I did not specifically
use
> JSON for data exchage; I simply sent back JavaScript.
>
> Just wondering if anyone out there was using this type of method
rather
> than XmlHttpRequest and XML.

#95 From: "Atif Aziz" <atif.aziz@...>
Date: Tue Aug 23, 2005 7:03 am
Subject: Re: JSON C# Parser
azizatif
Send Email Send Email
 
Hi Michael,

I have written such a parser in C#. The parser is an adaption of the
JSONTokener port available from Douglas Crockford's web site [1]. I
have re-factored the JSONTokener, JSONArray and JSONObject classes
to
be slightly more de-coupled with the eventual goal of allowing the
caller to dictate the object hierarchy that is deserialized by the
parser. In essence, the parser now works with an AST (Abstract
Syntax
Tree) strategy that can be implemented by anyone. The default
implementation, of course, simply deserializes into JSONObject and
JSONArray instances but that's precisely what can be changed now. I
have also a JSON writer implementation that does the converse. It
provides an AST interface and emits JSON as text. The advantage of
this approach is that you can even (for some odd reason) emit an XML
or binary of the JSON AST. Just one problem...you've just caught me
right before the point I was going to find a home for the sources
but
haven't gotten around to it. If you're interested in having a look
at
it sooner, please e-mail me and I can send the implementation to you
directly.

[1] http://www.crockford.com/JSON/cs/

--- In json@yahoogroups.com, Michael Schwarz <michael.schwarz@g...>
wrote:
> Hello,
>
> I will first introduce myself: I'm the author of the Ajax.NET
> (http://ajax.schwarz-interactive.de/ or
> http://weblogs.asp.net/mschwarz/) and using JSON to transport
objects
> from server-side .NET code to JavaScript.
>
> Currently I'm working on a parser (or converter) that will
create .NET
> objects on the server-side from a JSON string. I had a look at the
> JSON parser at http://www.json.org/ but ran into different
problems.
> Has anyone developed such a parser already or is working on it?
>
> CIAO
> Michael

#97 From: "incrediblybuilt" <incrediblybuilt@...>
Date: Mon Sep 5, 2005 6:52 pm
Subject: AJAJ calendar application
incrediblybuilt
Send Email Send Email
 
We are producing a calendar app that uses JSON as the interchange
format. You can check it out at www.kiko.com.

#98 From: "jeffrey_horner" <jeffrey_horner@...>
Date: Wed Sep 7, 2005 6:03 pm
Subject: Re: The State of JSON
jeffrey_horner
Send Email Send Email
 
--- In json@yahoogroups.com, "Douglas Crockford" <douglas@c...> wrote:
[...]
> I don't anticipate any further changes to JSON. The only additional
> feature I can foresee would be support for cyclical structures. This
> would not be possible in an ECMAScript subset, so the result would not
> be JSON.

Indeed. I would certainly use JSON if it contained cyclical
structures. Maybe
you could elaborate on this, maybe even show us some examples of how
you would consider implementing this?

#102 From: "lorphos" <sven@...>
Date: Fri Sep 23, 2005 3:15 pm
Subject: Re: AJAJ calendar application
lorphos
Send Email Send Email
 
--- In json@yahoogroups.com, "incrediblybuilt" <incrediblybuilt@y...>
wrote:
> We are producing a calendar app that uses JSON as the interchange
> format. You can check it out at www.kiko.com.

Interesting. Is the API going to be JSONRPC?

-Sven

#103 From: Peter Ring <pri@...>
Date: Thu Oct 6, 2005 5:18 pm
Subject: string vs. Unicode objects; json-py
peter17ring
Send Email Send Email
 
Is there a way to ensure that key names and string values are
represented as unicode objects by a JSON reader?

Specifically, I'm using json-py in a context where key names and string
values from JSON files will be used in an XML application. Using
json-py, JSON strings arbitrarily become Python strings (with an implied
utf-8 encoding) or Python Unicode objects. A little demonstration (if
there's some garbage in the example, it's supposed to be euro signs):

# -*- coding: utf-8 -*-
import json

print json.read("""{
    "ACCESS":     [ "Access", "€cess", "\u20access" ],
    "€CESS":      [ "Access", "€cess", "\u20access" ],
    "\u20acCESS": [ "Access", "€cess", "\u20access" ]
    }""")

Depending on the occurrence of '\uxxxx' characters in key names or
strings, the reader creates plain ol' strings (implied utf-8) or Unicode
objects:

{'ACCESS': ['Access', '\xe2\x82\xaccess', u'\u20access'],
'\xe2\x82\xacCESS': ['Access', '\xe2\x82\xaccess', u'\u20access'],
u'\u20acCESS': ['Access', '\xe2\x82\xaccess', u'\u20access']}

This is a PITA:
- The keys '\xe2\x82\xacCESS' and u'\u20acCESS' differ, though the
character values (Unicode code points) are identical; one is a (implied
utf-8 encoded) Python string, the other a Python Unicode object.
- In the application, the keys and string values will be consumed by XML
routines that live and breathe Unicode. Encoding issues should be
handled at the border to the system.

Should I patch json-py to emit strings only as Unicode objects? Why not
always use Unicode objects?

Kind regards
Peter Ring

#104 From: Jim Washington <jwashin@...>
Date: Thu Oct 6, 2005 7:00 pm
Subject: Re: string vs. Unicode objects; json-py
jimcburg
Send Email Send Email
 
Peter Ring wrote:

>Is there a way to ensure that key names and string values are
>represented as unicode objects by a JSON reader?
>
>Specifically, I'm using json-py in a context where key names and string
>values from JSON files will be used in an XML application. Using
>json-py, JSON strings arbitrarily become Python strings (with an implied
>utf-8 encoding) or Python Unicode objects. A little demonstration (if
>there's some garbage in the example, it's supposed to be euro signs):
>
># -*- coding: utf-8 -*-
>import json
>
>print json.read("""{
>   "ACCESS":     [ "Access", "€cess", "\u20access" ],
>   "€CESS":      [ "Access", "€cess", "\u20access" ],
>   "\u20acCESS": [ "Access", "€cess", "\u20access" ]
>   }""")
>
>Depending on the occurrence of '\uxxxx' characters in key names or
>strings, the reader creates plain ol' strings (implied utf-8) or Unicode
>objects:
>
>{'ACCESS': ['Access', '\xe2\x82\xaccess', u'\u20access'],
>'\xe2\x82\xacCESS': ['Access', '\xe2\x82\xaccess', u'\u20access'],
>u'\u20acCESS': ['Access', '\xe2\x82\xaccess', u'\u20access']}
>
>This is a PITA:
>- The keys '\xe2\x82\xacCESS' and u'\u20acCESS' differ, though the
>character values (Unicode code points) are identical; one is a (implied
>utf-8 encoded) Python string, the other a Python Unicode object.
>- In the application, the keys and string values will be consumed by XML
>routines that live and breathe Unicode. Encoding issues should be
>handled at the border to the system.
>
>Should I patch json-py to emit strings only as Unicode objects? Why not
>always use Unicode objects?
>
>
>
Hi, Peter

You have made an interesting case for the idea that strings read from
JSON in python should be python unicode objects.

For the time being, I think your plan for patching json-py to do what
you need is the right answer for your situation, particularly if your
project is time sensitive.  I do not have not much say-so on json-py,
but minjson.py is mine, and I think your solution is worth looking into,
and might just be part of the proper answer to the question of "handling
unicode."

Thanks,

-Jim Washington

#107 From: "Douglas Crockford" <douglas@...>
Date: Wed Oct 19, 2005 3:53 pm
Subject: Syntax
douglascrock...
Send Email Send Email
 
I added some grammar to www.JSON.org to describe strings and numbers.
This is not a change to the language. It is just completing the
grammar so that it conforms to the diagrams.

#108 From: "Will Coleda" <will@...>
Date: Fri Oct 21, 2005 10:20 pm
Subject: JSON on Parrot
will_coleda
Send Email Send Email
 
I just committed about half a JSON implementation into the parrot source tree
(converting
Parrot PMCs into JSON strings.)

Conversion the other way will probably be available in the next few days.

More information about parrot is available at http://www.parrotcode.org/.

#109 From: "technites80" <technites80@...>
Date: Wed Nov 2, 2005 8:12 am
Subject: J2ME implementation
technites80
Send Email Send Email
 
Hi,

I'm looking into developing a lightweight pull parser for JSON on mobile
devices. Is
anything like this already available?


John Wright

#110 From: Rob Lanphier <robla@...>
Date: Thu Nov 3, 2005 3:11 am
Subject: JSON schema
robla
Send Email Send Email
 
Hi all,

Below is a note that I originally sent to the json-php list, but realize
probably has broader applicability.

In the past week, I released my JSON-based project:
http://electorama.com/electowidget

It's a PHP library for adding rated balloting to CMS systems, starting
with MediaWiki, with a BSD license.

JSON is used as pretty much the sole storage format.  In some places,
I'm using it a bit like wiki markup for structured data.

One thing I'm starting to explore now is the role that a well-defined
schema could play.  I haven't seen any work on this so far, but I saw
that someone was working on a YAML schema, and I borrowed liberally from
that:
http://www.kuwata-lab.com/kwalify/

Here's the schema for my election configuration markup:
http://wiki.electorama.com/wiki/Election_Config_Schema

...which I used to generate this documentation:
http://wiki.electorama.com/wiki/Electowidget_Configuration_Reference

The nice part is that I didn't write the schema from scratch.  Rather, I
quickly hacked up a tool that took one of my election configuration
samples, and wrote a tool to derive a schema from that.  It wasn't
perfect, but it beat writing the schema from scratch.

Now that I have a schema, here's the areas I'd like to explore:

*  An optional validation step in the JSON parser.
*  A JavaScript JSON file edit interface which is automatically
generated from the schema file.
*  Cleaning up and releasing the code I've already got:
**  Generating a schema from a sample file
**  Generating documentation from a schema

Is there interest on this list in exploring these ideas?  Which ones
first?

Rob

#111 From: "pjdonnelly" <pjdonnelly@...>
Date: Thu Nov 3, 2005 9:11 pm
Subject: xsl to json
pjdonnelly
Send Email Send Email
 
has anyone tried to use xsl to transform xml to the json format?

#112 From: "technites80" <technites80@...>
Date: Sat Nov 5, 2005 8:46 am
Subject: Re: xsl to json
technites80
Send Email Send Email
 
Nope, but that's an idea I'll definitely have to steal sometime!


--- In json@yahoogroups.com, "pjdonnelly" <pjdonnelly@y...> wrote:
>
>
> has anyone tried to use xsl to transform xml to the json format?
>

#113 From: "fabiorecife" <fabiorecife@...>
Date: Tue Nov 8, 2005 6:57 pm
Subject: JSON on Delphi
fabiorecife
Send Email Send Email
 
#114 From: "fabiorecife" <fabiorecife@...>
Date: Tue Nov 15, 2005 11:18 am
Subject: For Delphi users of JSON
fabiorecife
Send Email Send Email
 
New release of uJSON.pas  :

Release new version 1.0.1 to correct the uJSON.pas (JSONArray.put and
JSONObject.getDouble) ...
more look:
http://sourceforge.net/forum/forum.php?forum_id=511254

------------------------

You find a delphi implementation from JSON , look this:
https://sourceforge.net/project/showfiles.php?group_id=94653&package_id=168952
or
https://sourceforge.net/projects/is-webstart/

#115 From: "malcontent123" <malcontent@...>
Date: Fri Nov 18, 2005 10:10 am
Subject: VB implementation.
malcontent123
Send Email Send Email
 
I am looking for a VB implementation of the JSON data format. I am
talking about VB 6 not .NET preferably in native VB code so I don't
have another DLL dependency in my project.

If anybody knows of one I would very much appreciate hearing about it.

Thank you very much.

#116 From: MPCM <WickedLogic@...>
Date: Fri Nov 18, 2005 2:08 pm
Subject: Re: VB implementation.
mpcmtechnolo...
Send Email Send Email
 
I haven't found one in my searches....,

But I've considered writing one or at least starting one as a base point.
Since vb doesn't support named arrays, I'm guessing we would use collections
by default? If there is enough interest, I can probably at least get a
project started for it and the bulk of it done some weekend.

Anyone else know of an existing project, or have an interest in one being
started? (again, vb 6 ... not .net)

--
Matt


[Non-text portions of this message have been removed]

#117 From: "Atif Aziz" <atif.aziz@...>
Date: Fri Nov 18, 2005 2:37 pm
Subject: Re: VB implementation.
azizatif
Send Email Send Email
 
I am not aware of any VB6 implementation, but one of the interesting things you
can do is use JavaScript directly from within VB6 without having to add any
external dependencies. You also have to bear in mind that due to lack of
reflection and dynamic objects in VB6, it will be hard to have a native
implementation anyhow. Your best bet would be to go with a dictionary-like
object. By hosting JavaScript in VB6, however, you gain a whole bunch of
benefits, first of which is that you can directly use the JavaScript JSON
implementation from Douglas Crockford or rely on eval (when deserializing) to do
the trick. Here's some VB6 code to illustrate my point:

Sub Main()

     Dim Script: Set Script = CreateObject("MSScriptControl.ScriptControl.1")
     Script.Language = "JavaScript"

     Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject")
     Script.AddCode FSO.OpenTextFile("json.js").ReadAll()

     Dim Point
     Set Point = Script.CodeObject.JSON.parse("{ ""x"" : 1, ""y"" : 2 }")

     Debug.Print Point.x
     Debug.Print Point.y

     Debug.Print CallByName(Point, "x", VbGet)
     Debug.Print CallByName(Point, "y", VbGet)

End Sub

The MS ScriptControl object that is created at the beginning is an automation
wrapper for scripting engines that support ActiveX Scripting, which covers
JavaScript  and VBScript. Note that this does not really add a dependency
because the MS ScriptControl has been shipping with Windows since a while now
(e.g., msscript.ocx ships and installs with Windows 2000). You should be able to
package your application without it. Next, setting the Language property to
"JavaScript" causes the control to fetch and host the JavaScript engine. I then
assume you have json.js lying around somewhere on disk and load its contents
into the scripting engine. At this point, the script is parsed and the JSON is
ready to be used. All you need to do to call JavaScript functions is go over the
CodeObject property. As you can see above, I get JSON.parse to return a
JSON-ified point object with an x and y property. You can access those
properties using the normal property-accesor syntax in VB.  If case-sensitivity
is an issue, as it can be in a case-insensitive language like VB and the IDE
that can sometimes change casing behind your back, I suggest using the
CallByName function where the exact case of the property you wish to read/write
can be specified as a string. I have also shown how to do this above.

Going the other way is harder, that is getting the JSON format for a VB object
is much harder. Again, this is due to the limited way in which a VB object
exposes itself to JavaScript since the languages are based on different
capabilities. In other words, you won't get the expected results if you simply
pass a VB object to JSON.stringify. But perhaps you can use the script control
to bridge the gap. In other words, when it comes to JSON, just use JavaScript
from VB. Create the objects you want to JSON-ify via JavaScript as script code.

- Atif


--- In json@yahoogroups.com, "malcontent123" <malcontent@u...> wrote:
>
> I am looking for a VB implementation of the JSON data format. I am
> talking about VB 6 not .NET preferably in native VB code so I don't
> have another DLL dependency in my project.
>
> If anybody knows of one I would very much appreciate hearing about it.
>
> Thank you very much.
>




[Non-text portions of this message have been removed]

#118 From: MPCM <WickedLogic@...>
Date: Fri Nov 18, 2005 3:39 pm
Subject: Re: Re: VB implementation.
mpcmtechnolo...
Send Email Send Email
 
I just tried that on my machine and it threw a lovely warning from
Norton about Possible Malicious scripts running (standard error, not
something actually malicious). I'm not thinking that this would be a
viable option if in fact this happens for others as well.

Although you would not be able to pass native vb objects into a json
format easily, it still would be very useful to be able to decode json
into native variable types, and at at least be able to convert viable
data formats into json.

I'm sure for most of us, it's meant to make getting data from json
speaking platforms (usually web based) to our vb apps more easily, and
sending light messages back.

Otherwise we are just doing some type of delimiting ourselves anyway,
so a standard format, even if it doesn't match fully, would still be
useful. I'll post back sometime next week, as I think I will be able
to put something together to do this.

--
Matt

#119 From: "Atif Aziz" <atif.aziz@...>
Date: Mon Nov 21, 2005 9:39 am
Subject: RE: Re: VB implementation.
azizatif
Send Email Send Email
 
Hi Matt,

Ah, yes, I don't have Norton software on my PC so I did not get that
warning on my machine when running the code I posted. I can see how this
would a problem for some, and frankly, it was just to show how you can
get up and running immediately with JSON in VB6 without investing too
much time upfront. With proper encapsulation, you could always revisit
the code and port it to a native implementation once you had the upper
bits done, but I'm sure you are the better judge of how to approach the
problem in your case. This could get a little off-topic, but my personal
belief is that scripting security warnings are completely useless for
most users and even administrators because they cannot make an informed
decision about most of those warnings. The responsibility to inform,
therefore, falls upon the application provider in the shape of README
files (which are not really read that much anyhow) or making early tests
at start-up. The latter approach allows one to tell the user or
administrator that your software requires a particular technology that
appears to have been blocked. This is happening today with ports and
pop-ups in browser and so scripting in desktop applications does not
appear to be an exception.

>>
Although you would not be able to pass native vb objects into a json
format easily, it still would be very useful to be able to decode json
into native variable types, and at at least be able to convert viable
data formats into json.
<<

I totally agree. I just think that the lack of reflection and expando
objects make it difficult to have such an implementation in VB6, but not
impossible. I can imagine that CallByName for dynamic invocation of
property accessors and TLBINF32.DLL for reflection would be your best
friends here in a native implementation.

- Atif

-----Original Message-----
From: json@yahoogroups.com [mailto:json@yahoogroups.com] On Behalf Of
MPCM
Sent: Friday, November 18, 2005 4:39 PM
To: json@yahoogroups.com
Subject: Re: [json] Re: VB implementation.

I just tried that on my machine and it threw a lovely warning from
Norton about Possible Malicious scripts running (standard error, not
something actually malicious). I'm not thinking that this would be a
viable option if in fact this happens for others as well.

Although you would not be able to pass native vb objects into a json
format easily, it still would be very useful to be able to decode json
into native variable types, and at at least be able to convert viable
data formats into json.

I'm sure for most of us, it's meant to make getting data from json
speaking platforms (usually web based) to our vb apps more easily, and
sending light messages back.

Otherwise we are just doing some type of delimiting ourselves anyway,
so a standard format, even if it doesn't match fully, would still be
useful. I'll post back sometime next week, as I think I will be able
to put something together to do this.

--
Matt




Yahoo! Groups Links

#120 From: "James" <jblack@...>
Date: Wed Nov 30, 2005 7:17 pm
Subject: re: first time using JSON, servlet throws exception
jblack1395
Send Email Send Email
 
I package up the data from a form, and send it to my servlet. This is
what the servlet receives when I get the parameter. I don't know if
there is a problem with this file itself or what.

{"gradedata": [{"cntr": "1","grade": "C","lastdateattended":
""}{"cntr": "2","grade": "C","lastdateattended": ""}{"cntr":
"3","grade": "C","lastdateattended": ""}{"cntr": "4","grade":
"C","lastdateattended": ""}{"cntr": "5","grade":
"D-","lastdateattended": ""}{"cntr": "6","grade":
"C","lastdateattended": ""}{"cntr": "7","grade":
"C","lastdateattended": ""}{"cntr": "8","grade":
"C","lastdateattended": ""}{"cntr": "9","grade":
"C","lastdateattended": ""}{"cntr": "10","grade":
"C","lastdateattended": ""}{"cntr": "11","grade":
"C","lastdateattended": ""}{"cntr": "12","grade":
"F","lastdateattended": "11/01/2005"}{"cntr": "13","grade":
"C","lastdateattended": ""}{"cntr": "14","grade":
"C","lastdateattended": ""}{"cntr": "15","grade":
"C","lastdateattended": ""}{"cntr": "16","grade":
"C","lastdateattended": ""}{"cntr": "17","grade":
"C","lastdateattended": ""}{"cntr": "18","grade":
"D","lastdateattended": ""}{"cntr": "19","grade":
"C","lastdateattended": ""}{"cntr": "20","grade":
"D+","lastdateattended": ""}{"cntr": "21","grade":
"F","lastdateattended": "11/03/2005"}{"cntr": "22","grade":
"C","lastdateattended": ""}{"cntr": "23","grade":
"C","lastdateattended": ""}{"cntr": "24","grade":
"C","lastdateattended": ""}{"cntr": "25","grade":
"C","lastdateattended": ""}{"cntr": "26","grade":
"C","lastdateattended": ""}{"cntr": "27","grade":
"D-","lastdateattended": ""}{"cntr": "28","grade":
"D-","lastdateattended": ""}{"cntr": "29","grade":
"C","lastdateattended": ""}]}

I call this function:
		 JSONObject jsonobj = null;
		 try {
			 jsonobj = new JSONObject(grades);
		 } catch (ParseException e1) {
			 // TODO Auto-generated catch block
			 e1.printStackTrace();
		 }


I get a syntax error in the JSONTokener class.

I want to have an array where each item has three values.

Thank you for your help.

#121 From: MPCM <WickedLogic@...>
Date: Wed Nov 30, 2005 7:33 pm
Subject: Re: re: first time using JSON, servlet throws exception
mpcmtechnolo...
Send Email Send Email
 
Looks like you need comma between your array values (objects in your case);

On 11/30/05, James <jblack@...> wrote:
>  I package up the data from a form, and send it to my servlet. This is
>  what the servlet receives when I get the parameter. I don't know if
>  there is a problem with this file itself or what.
>
>  {"gradedata": [{"cntr": "1","grade": "C","lastdateattended":
>  ""}{"cntr": "2","grade": "C","lastdateattended": ""}{"cntr":
>  "3","grade": "C","lastdateattended": ""}{"cntr": "4","grade":
>  "C","lastdateattended": ""}{"cntr": "5","grade":
>  "D-","lastdateattended": ""}{"cntr": "6","grade":
>  "C","lastdateattended": ""}{"cntr": "7","grade":
>  "C","lastdateattended": ""}{"cntr": "8","grade":
>  "C","lastdateattended": ""}{"cntr": "9","grade":
>  "C","lastdateattended": ""}{"cntr": "10","grade":
>  "C","lastdateattended": ""}{"cntr": "11","grade":
>  "C","lastdateattended": ""}{"cntr": "12","grade":
>  "F","lastdateattended": "11/01/2005"}{"cntr": "13","grade":
>  "C","lastdateattended": ""}{"cntr": "14","grade":
>  "C","lastdateattended": ""}{"cntr": "15","grade":
>  "C","lastdateattended": ""}{"cntr": "16","grade":
>  "C","lastdateattended": ""}{"cntr": "17","grade":
>  "C","lastdateattended": ""}{"cntr": "18","grade":
>  "D","lastdateattended": ""}{"cntr": "19","grade":
>  "C","lastdateattended": ""}{"cntr": "20","grade":
>  "D+","lastdateattended": ""}{"cntr": "21","grade":
>  "F","lastdateattended": "11/03/2005"}{"cntr": "22","grade":
>  "C","lastdateattended": ""}{"cntr": "23","grade":
>  "C","lastdateattended": ""}{"cntr": "24","grade":
>  "C","lastdateattended": ""}{"cntr": "25","grade":
>  "C","lastdateattended": ""}{"cntr": "26","grade":
>  "C","lastdateattended": ""}{"cntr": "27","grade":
>  "D-","lastdateattended": ""}{"cntr": "28","grade":
>  "D-","lastdateattended": ""}{"cntr": "29","grade":
>  "C","lastdateattended": ""}]}
>
>  I call this function:
>              JSONObject jsonobj = null;
>              try {
>                    jsonobj = new JSONObject(grades);
>              } catch (ParseException e1) {
>                    // TODO Auto-generated catch block
>                    e1.printStackTrace();
>              }
>
>
>  I get a syntax error in the JSONTokener class.
>
>  I want to have an array where each item has three values.
>
>  Thank you for your help.
>
>
>
>
>
>
>  ________________________________
>  YAHOO! GROUPS LINKS
>
>
>  Visit your group "json" on the web.
>
>  To unsubscribe from this group, send an email to:
>  json-unsubscribe@yahoogroups.com
>
>  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>  ________________________________
>


--
Matthew P. C. Morley
MPCM Technologies Inc.

#122 From: "James" <jblack@...>
Date: Wed Nov 30, 2005 8:30 pm
Subject: Re: first time using JSON, servlet throws exception
jblack1395
Send Email Send Email
 
--- In json@yahoogroups.com, MPCM <WickedLogic@g...> wrote:
>
> Looks like you need comma between your array values (objects in your
case);

   Thank you for the response. Now I have modified my array, and am now
having a different problem.

Here is my java code:
temparray = jsonarray.getJSONArray(t);
System.out.println(temparray);
cntr = temparray.getInt(0);
grade[t] = temparray.getString(1);
pidm[t] = bean.getBean()[cntr].getPidm();
lastAttenddate[t] = temparray.getString(2);

   I get an error on temparray.getInt(0) with, JSONObject[0] is not a
number.

When I had temparray.getString(1) first the error was:
NoSuchElementException: JSONArray[1] not found.

temparray = [{"cntr": 1, "grade": "C", "lastdateattended": ""}]

I don't know what I am doing wrong, now.

Thank you for your help.

#123 From: Martin Cooper <mfncooper@...>
Date: Wed Nov 30, 2005 11:18 pm
Subject: Re: Re: first time using JSON, servlet throws exception
mfncooper
Send Email Send Email
 
On 11/30/05, James <jblack@...> wrote:
>
> --- In json@yahoogroups.com, MPCM <WickedLogic@g...> wrote:
> >
> > Looks like you need comma between your array values (objects in your
> case);
>
>   Thank you for the response. Now I have modified my array, and am now
> having a different problem.
>
> Here is my java code:
> temparray = jsonarray.getJSONArray(t);
> System.out.println(temparray);
> cntr = temparray.getInt(0);
> grade[t] = temparray.getString(1);
> pidm[t] = bean.getBean()[cntr].getPidm();
> lastAttenddate[t] = temparray.getString(2);
>
>   I get an error on temparray.getInt(0) with, JSONObject[0] is not a
> number.
>
> When I had temparray.getString(1) first the error was:
> NoSuchElementException: JSONArray[1] not found.
>
> temparray = [{"cntr": 1, "grade": "C", "lastdateattended": ""}]


This is an array with a single element, and that element is an object. Your
original array, after you fixed the commas, was an array of objects. It
looks like you are trying to treat the objects as if they are arrays, which
they are not.

--
Martin Cooper


I don't know what I am doing wrong, now.
>
> Thank you for your help.
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>


[Non-text portions of this message have been removed]

Messages 88 - 123 of 1953   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help