ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Workaround bad JSON data?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Workaround bad JSON data?

    This is not a YAJL issue, but I'm wondering if anyone has worked around an issue like this?

    We are calling a Vertex tax API which should send us back numeric data, but they are sending us scientific notation in one situation. The problem is on their side, but it won't be fixed until the next release. I thought I could get around it and monitor or trap it, but I can't figure it out. The data is blowing up the YAJL itself because it's bad data. I thought I could just tell it to bring it in as a string and then convert it, but YAJL doesn't like that because it's not really a string.

    TIA.
    Your friends list is empty!

  • #2
    Can you provide an example of the bad data?

    Comment


    • #3
      Code:
      [FONT=Calibri][FONT=Consolas][COLOR=#a31515]"effectiveRate"[/COLOR][/FONT][FONT=Consolas][COLOR=black]: [/COLOR][/FONT][FONT=Consolas][COLOR=#098658]4.99E-4[/COLOR][/FONT][FONT=Consolas][COLOR=black],[/COLOR][/FONT][/FONT]
      Your friends list is empty!

      Comment


      • #4
        It is not bad data it is a valid JSON representation of a numeric value.
        Instead of using YAJL you may intent to decompose your JSON data with SQL ... SQL converts the numeric value correctly:

        JSON_TABLE - Numeric Value
        JSON_VALUE Numeric Value
        ... and SQL can be embedded in RPG

        Birgitta

        Comment


        • #5
          Thank you. Got it working.
          Last edited by mjhaston; July 20, 2022, 10:47 AM.
          Your friends list is empty!

          Comment


          • #6
            Yeah, this is valid JSON data. It is in floating point format, and YAJL does appear to interpret it correctly -- however, my RPG interface for YAJL (YAJLR4) does not. The RPG interface uses RPG's %DEC built-in function, which doesn't support floating point numbers.

            I can fix that.

            Comment

            Working...
            X