PxPlus User Forum

Twitter Twitter Twitter

Author Topic: JSON files  (Read 1417 times)

Mike Hatfield

  • Gold Member
  • ****
  • Posts: 70
    • View Profile
JSON files
« on: August 22, 2019, 11:45:24 PM »
Hi All,

When I create JSON files from PxPlus each element terminates with comma+0A.
I note that most JASON files we process from other sources are a continuous stream of data with only a comma between elements.
If I parse the PxPlus file at https://jsonformatter.org/ is validates OK.

Is this correct for PxPlus or should I be doing something to eliminate the 0A ?

SMPRICE_JSON:
CLEAR SMPRICEJSON${ALL}
LET SMPRICEJSON$["Price Date"]=""
LET SMPRICEJSON$["Products.1.Inventory_SKU"]=""
LET SMPRICEJSON$["Products.1.List_Price"]=""

LET SMPRICEJSON$["Price Date"]=DYMD$
FOR I=1 TO 5
READ RECORD (ICM1)ICM1$
LET SMPRICEJSON$["Products."+STR(I)+".SKU"]=ICM1.STOCK_CODE$
LET SMPRICEJSON$["Products."+STR(I)+".Price"]=STR(ICM1.PRICES[1])
NEXT I
LET SMPRICE$=DIM(LIST EDIT SMPRICEJSON${ALL})
LET JSONFILE$="/hit/temp/czapijson.json";
       ERASE JSONFILE$,ERR=*PROCEED;
       SERIAL JSONFILE$;
       OPEN (HFN,ISZ=LEN(SMPRICE$))JSONFILE$;
       WRITE RECORD (LFO)SMPRICE$;
       CLOSE (LFO)

Thanks
Mike H

koenv

  • Member
  • **
  • Posts: 12
    • View Profile
Re: JSON files
« Reply #1 on: August 23, 2019, 03:58:37 AM »
Replace
LET SMPRICE$=DIM(LIST EDIT SMPRICEJSON${ALL})
with
LET SMPRICE$=DIM(LIST SMPRICEJSON${ALL})