Parsing JSON in Luan

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Parsing JSON in Luan

Thermo
This post was updated on .
What would be a good way to approach parsing JSON in Luan?

I am extracting the price of gold from here:

https://query1.finance.yahoo.com/v7/finance/quote?symbols=GC=F

For now I am doing:

String.sub(res,String.find(res,"ask")+5,String.find(res,"bidSize")-3)

where res is the content of the yahoo url I posted. It works, but it will stop working if, for example, a new field is added between "ask" and "bidSize", so I am wondering if there is a built-in way to parse JSON in Luan.
Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON in Luan

fschmidt
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON in Luan

Thermo
Simple and it works, thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON in Luan

talis
This post was updated on .
 Lua is a simplified compiled replacement for C , I read LUAN does not parse JSON
 could u pls. clarify, as the link simply sends one to LUAN manual.

  Certainly prefer simple syntactic rep, tho like every high level lang, no compilers control memory physical address space
(its managed on chip by Intel) if one needs physical address an option for fencing * more overhead)

   I have not looked at embedded C versions since losing all of 30 years work, to thieves
   recall TINY C  and compilers for PIC32  (great Harvard arch  w/ 5 stage pipeline CPU )
    but need full mem physical control on a Xeon 2690 w/ 256 GB RAM, without overhead

   Naturally with stack and heap Arch, that is impossible  without expensive fencing..
   due to checking with the VM , for fear of mem collisions, et al .. what is most efficient flat mem addressing >90 % of avail  DRAM  ( 900GB )  which LANG  in a POSIX or UNIX (Linux) envir ?

bak to ASM .. does  ASM.js  allow direct control  my mind a virtual sandbox, is still label abstracted
  and memory  unsafe ,   like  C  or  Lua  or  even Luan

   http://asmjs.org/spec/latest/

  Spider Monkey users don't care ( nor anyone) what address of mem is used , only to access
  Browser embedded  functions with javascript , the browser is the OS.  Is fencing simpler here?

  Or is this as good as it gets ?  :  sect 5.6  of above link.

  A function table is a VariableStatement of the form:

var x:Identifier = [f0:Identifier, f:Identifier,…];

The function table x is stored in the global environment with type imm ((σ,…) → τ)[n] where (σ,…) → τ is the type of f in the global environment and n is the length of the array literal.

  Java is a jungle of libraries, all of which produce memory leakage ( as does any stack )
   pls comment to similarity to  C++  /   as they both written in C

  I was keen when JMS  came out, bought the textbook, 1988 elegant as the queues were
  one could not write a TCP Server to handle 300,000 simultaneous sessions on a single CPU
    One has been written to handle 600,000  sessions on a pair of Sockets.  1 pair.

   Yes a bit cross country, tho your experience may have quik answer for a memory safe" Lang
    or rather compiler for embedded that may also run on a Xeon Intel, bypassing mem management
    like the IBM  P8 , Is  IBM the only Server Arch with such a compiler ?  Most don't even kno it .

   Messaging Services now exist in every DB  simply as another  virtual stack,  w / leakage.
   U may wonder why ?  for a 1 TB in-memory DB without key value pairs.
Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON in Luan

fschmidt
Administrator
Luan does parse JSON as the example that I posted shows.

Luan is for application programming, not low level programming.  I think the best language for writing libraries is Java (ignoring the new Java features).  And the best language for low level system programming is C.  So Luan, Java, and C should cover most programming needs.
Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON in Luan

talis
 Problem with Java, is overheads, even when Agent services are used, in a shared global environment.

 C has synchronising overheads needing SpinLocks / Mutex, as any compiled target may be left unguarded.

 This is main problem with all  languages ( mostly written in C  or  Go ) Malloc is expensive as are kernel calls, et al..

 Fact of Life,  but a real bottleneck to my style of programming ( DSP ) 
 Funny how no-one cares a wooly sheep dip , about Overhead,  time-slice or benchmarking code snippets

 i need to use  logic programming  built within an Actor model..  without the tea-total of JAVA.  Too much overhead, JMS too slow
 Reality needs a Event Lib   that interfaces directly to status registers / instruction implied  logic return registers (that exists) that 
 unblock  a  wait-thread without polling ( without testing  a condition in software ) 

Once the actor model was initially defined, an important challenge was to understand the power of the model relative to Robert Kowalski's thesis that "computation can be subsumed by deduction". Hewitt argued that Kowalski's thesis turned out to be false for the concurrent computation in the actor model (see Indeterminacy in concurrent computation).

Nevertheless, attempts were made to extend logic programming to concurrent computation. However, Hewitt and Agha [1991] claimed that the resulting systems were not deductive in the following sense: computational steps of the concurrent logic programming systems do not follow deductively from previous steps (see Indeterminacy in concurrent computation). Recently, logic programming has been integrated into the actor model in a way that maintains logical semantics.


Q : where is  such an efficient FrameWork Found ??  ( Cant be made without hardware assisted  condition code unblockers )

 https://arxiv.org/vc/arxiv/papers/1008/1008.1459v8.pdf


On Wed, May 5, 2021 at 4:21 AM fschmidt [via Luan Forum] <[hidden email]> wrote:
Luan does parse JSON as the example that I posted shows.

Luan is for application programming, not low level programming.  I think the best language for writing libraries is Java (ignoring the new Java features).  And the best language for low level system programming is C.  So Luan, Java, and C should cover most programming needs.



If you reply to this email, your message will be added to the discussion below:
http://forum.luan.software/Parsing-JSON-in-Luan-tp27p90.html
To unsubscribe from Parsing JSON in Luan, click here.
NAML