Hi :tada:, is there a *solution to have a good JSO...
# troubleshooting
a
Hi πŸŽ‰, is there a solution to have a good JSON Serialization and avoid useless backslash
\
and double quotes
""
in result then using multiple
JSON_ARRAYAGG
and
JSON_OBJECT
in successive JSON aggregation. I am stuck. Apache Flink: v1.15. --- Result: observe backslash \ between json and double quote between object {} and array []:
Copy code
[
  {
  "my_code": "code1",
  "challenges":"["{\"count":50, \"challenge\":106, \"my_rank":1}"]"
  },
{
  "my_code": "code2",
  "challenges":"["{\"count":50, \"challenge\":106, \"my_rank":1}"]"
  }
]
Code:
Copy code
SQL_A as (
SELECT
    offers,
    my_code,
    JSON_ARRAYAGG(
        JSON_OBJECT(
                KEY 'challenge' VALUE challenge,
                KEY 'my_rank' VALUE my_rank,
                KEY 'count' VALUE count
                )
    ) as challenges
FROM
    ranked_competitions
WHERE
    bet_rank_per_offer_catalog_per_sport <= 5
GROUP BY
    offers, sport_code
),

SQL_B as (
SELECT
    offers,
    JSON_ARRAYAGG(
      JSON_OBJECT(
        KEY 'my_code' VALUE my_code,
        KEY 'challenges' VALUE challenges
        )
      ) as 
    
FROM
    SQL_A
GROUP BY
    offers
)