Giter Club home page Giter Club logo

Comments (3)

kshji avatar kshji commented on August 19, 2024

Version AJ 93v-1203-g8d977fd3

There are more strange in read -m json. Make same read twice. Result is different. 1st reading works almost everytime ... but second reading some reading error. zakukai foo problem is also interesting.

Unset json variable not helps.

nvtree.c has some parsing problem ?

print "========================================================="
read -m json some <<EOF
{
        "squanchy" : "cromulent",
        "num" : 1,
        "text": "foo",
        "notbool": "true",
        "bool": true ,
        "endval" : "yes"
}
EOF

print "-------------------------------"
print -j some
print "-------------------------------"
print $some
print "-------------------------------"
printf "%(json)B\n" some
print "-------------------------------"
printf "%(json)q\n" $some
print "-------------------------------"
printf "%#(csv)q\n" $some
print "-------------------------------"
printf "%(csv)B\n" some

print "========================================================="
read -m json some <<EOF
{
        "squanchy" : "cromulent",
        "num" : 1,
        "text": "foo",
        "notbool": "true",
        "bool": true ,
        "endval" : "yes"
}
EOF

print "-------------------------------"
print -j some
print "-------------------------------"
print $some
print "-------------------------------"
printf "%(json)B\n" some
print "-------------------------------"
printf "%(json)q\n" $some
print "-------------------------------"
printf "%#(csv)q\n" $some
print "-------------------------------"
printf "%(csv)B\n" some

And output is

=========================================================
-------------------------------
{
        "bool": true,
        "endval": "yes",
        "notbool": "true",
        "num": 1,
        "squanchy": "cromulent",
        "text": "foo"
}
-------------------------------
( _Bool bool=true endval=yes notbool=true typeset -l -E num=1 squanchy=cromulent text=foo )
-------------------------------
{
        "bool": true,
        "endval": "yes",
        "notbool": "true",
        "num": 1,
        "squanchy": "cromulent",
        "text": "foo"
}
-------------------------------
'('
_Bool
bool=true
endval=yes
notbool=true
typeset
-l
-E
num=1
squanchy=cromulent
text=foo
')'
-------------------------------
"("
_Bool
"bool=true"
"endval=yes"
"notbool=true"
typeset
"-l"
"-E"
"num=1"
"squanchy=cromulent"
"text=foo"
")"
-------------------------------
(
        _Bool bool=true
        endval=yes
        notbool=true
        typeset -l -E num=1
        squanchy=cromulent
        text=foo
)
=========================================================
json5.sh[31]: read: line 48: ": not found
-------------------------------
{
}
-------------------------------
( )
-------------------------------
{
}
-------------------------------
'('
')'
-------------------------------
"("
")"
-------------------------------
(
)

Previosly next example didn't work, but in this version it works fine

read -m json person <<EOF
{
    "first" : "My",
    "last" : "Name",
    "email" : "[email protected]",
    "lucky" : 13,
    "quarter" : 0.25,
    "empty" : null,
    "nerd" : true,
    "lotto" : [ 9, 12, 17, 38, 45, 46 ],
    "children" : [ "boy", "girl" ]
}
EOF



print "-------------------------------"
print "$person"
print "-------------------------------"
print -r "$person"
print "-------------------------------"
print ${person.email}
print "-------------------------------"
print ${person.lotto[*]}
print "-------------------------------"
print -j person
print "-------------------------------"

unset person

compound person
compound person=(firstname="John" lastname="Some" age=32)
print -j person
print "-------------------------------"
printf "%(json)B\n" person
print "-------------------------------"

But if you read twice same lines, second reading give error ...

I have tested built ksh

  • Win10 WSL Ubuntu 18.04
  • Debian 9

Same problem.

from ast.

krader1961 avatar krader1961 commented on August 19, 2024

I realize the JSON functionality in Korn Shell isn't fully mature yet, ....

Not only is native JSON support by ksh not mature it also has significant bugs. See issue #820. My recommendation is to remove the JSON related code. At the moment, by necessity, the focus is on a ksh release that could replace ksh93u+ from 2012 but that is much easier to maintain.

from ast.

siteshwar avatar siteshwar commented on August 19, 2024

Since current implementation for json support is broken, we are going to disable it in next release. We may reintroduce it in future, but it won't be done without solid testing. Closing this issue as it does not serve any purpose now.

from ast.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.