« first day (1647 days earlier)      last day (1709 days later) » 

10:45 PM
This will probably sound like spam. I'll try to make it sound not spamy:

I'd like to pay someone to answer a Jython question of mine that hasn't received much attention. I might try to use UpWork (a freelancing company).

Is this sort of thing acceptable on SO/SE? I've considered asking a META question about this. But I've been vigorously down voted so often lately that I'm feeling a bit nervous about posting again.

Cheers.
0
Q: Jython: Parse JSON object to get value (object has array)

User1973I have a JavaScript library script that parses a JSON object and returns the value from the ZONE field. var obj = JSON.parse(json_text); parsed_val = obj.features[0].attributes.ZONE I would like to convert the JavaScript code to Jython. This is what I've tried: from com.ibm.json.java import...

 
11:01 PM
Jython has the standard json library built in - why aren't you using that?
 
@MisterMiyagi Good question.

If I add **import json** to my script and run it, I get this error: **ImportError: No module named json in <script> at line number 1**.

I'm just an novice, but I think maybe Maximo's version of Jython is missing a bunch of Python libraries.
@MisterMiyagi
And if I try to reference a JSON function without importing the JSON library like this:
json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])

...then I get an error:
NameError: name 'json' is not defined in <script> at line number 5
Sample code taken from here:
https://docs.python.org/2/library/json.html
 
@User1973 Is there a reason you have to use this version of Jython that you think is broken? If not why not try a different version?
 
11:17 PM
@Peilonrayz
Unfortunately, I don't have control of the Maximo software, the server, or the version of Jython that it was deployed with. I get what I get.
I have Maximo 7.6.1.1 which is the latest version.
 
truth be told, not having access to any standard Python functionality makes it unlikely that you will find help from Python programmers
 
Looks like Jython just doesn't have JSON support builtin. this dead link half shows that and so does this SO post.
 
my Jython 2.7.0 has it out of the box
 
11:34 PM
It's weird. I seem to have Jython 2.7.0, but I can't seem to access the JSON library.

Would IBM really have stripped out libraries from their Jython implementation? Seems kind of implausible.
 
Yeah, just installed it and it does come with it.
Check if Lib/json exists
 
@User1973 it is not uncommon for vendors to remove packages (e.g. pip), though removing json seems excessive
 
@Peilonrayz
It doesn't seem to like the slash in it:
import Lib/json

Here's a screen capture:
https://i.stack.imgur.com/wBqA6.png
@MisterMiyagi
That's good to know that vendors do remove packages. Thanks.
Yeah, it seems like IBM removed all of the packages that I need.
 
wim
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
[OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.8.0_171
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/fwierzbicki/hg/jython/jython/dist/Lib/json/__init__.py", line 108, in <module>
  File "/Users/fwierzbicki/hg/jython/jython/dist/Lib/json/decoder.py", line 24, in <module>
  File "/Users/fwierzbicki/hg/jython/jython/dist/Lib/json/decoder.py", line 18, in _floatconstants
hah
Jython is a piece of crap
 
11:50 PM
@wim "hah" indeed. I don't know what I'm supposed to do with it.
@wim Do you use Jython?
 
wim
no, I don't trust any technology with a J in the name
 
What about an analogue jukebox?
 

« first day (1647 days earlier)      last day (1709 days later) »