[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ftpapi] question on using the tree method to read a JSON file



Hello Georgeann,

RPG does not allow a dash in a variable name.  You are trying to name your field 'arrt-id', but this isn't possible.  RPG will assume you are trying to do subtraction (arrt minus id).

There is nothing that requires your RPG variable names to match the JSON names.  You are simply defining a regualr RPG data structure and assigning a value to it... so you can code this any way you wish.  Perhaps you are thinking of the DATA-INTO method?  In DATA-INTO, the field names in RPG must match the document... but this is not the case with the tree method.

For example, you could do something like this:

when key = 'arrt-id';
  Result.list(i).MyBrotherIsAMonkey = yajl_get_string(val);

Haha, as you can see, the field name does not matter, use whichever field name you wish.  

If you decided to use DATA-INTO instead of the tree method, there's a feature that allows the names in the document to be 'converted' to RPG names...   but, that's very different from the tree method, so I won't confuse the issue further unless you reply and say you'd like to use DATA-INTO instead of the tree method.

-SK


On 9/30/2020 2:40 PM, Georgeann Rybak wrote:

The Json file I am reading has a ‘-‘ in the field name  arrt-id

 

I am using the following as part of a larger select statement

when key = 'arrt-id';                             

  Result.list(i).arrt-id = yajl_get_string(val);  

  arrtidsave  = result.list(i).arrt-id;      

 

I get back a 7030 on the highlighted statement saying id not defined.  The one above it gets a RNF5347.

 

I need to use arrt-id because that is what is in the JSON file, right?

 

I am not sure how to get around it.

 

Any ideas are appreciated,

 

Thanks,

      

 

Georgeann Rybak

 


Software Engineer, Information Technology

The American Registry Of Radiologic Technologists®

 


Direct Phone & Fax651.681.3133 | Main Phone651.687.0048

1255 Northland Drive, St. Paul, MN 55120

arrt.org

 


 


-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi