Skip to content

Commit

Permalink
fix: getJsonFromArrayOfJson added in necessary places
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja committed Oct 29, 2024
1 parent 789639f commit 24ca6ff
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/Utilities/Utils.res
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ type dateTimeFormat = {resolvedOptions: unit => options}

open ErrorUtils

let getJsonFromArrayOfJson = arr => arr->Dict.fromArray->JSON.Encode.object

let messageWindow = (window, ~targetOrigin="*", messageArr) => {
window->postMessage(messageArr->Dict.fromArray->JSON.Encode.object, targetOrigin)
window->postMessage(messageArr->getJsonFromArrayOfJson, targetOrigin)
}

let messageTopWindow = (~targetOrigin="*", messageArr) => {
Expand Down Expand Up @@ -78,8 +80,6 @@ let getInt = (dict, key, default: int) => {
->Float.toInt
}

let getJsonFromArrayOfJson = arr => arr->Dict.fromArray->JSON.Encode.object

let getFloatFromString = (str, default) => str->Float.fromString->Option.getOr(default)

let getFloatFromJson = (json, default) => {
Expand Down Expand Up @@ -319,13 +319,12 @@ let getFailedSubmitResponse = (~errorType, ~message) => {
[
(
"error",
[("type", errorType->JSON.Encode.string), ("message", message->JSON.Encode.string)]
->Dict.fromArray
->JSON.Encode.object,
[
("type", errorType->JSON.Encode.string),
("message", message->JSON.Encode.string),
]->getJsonFromArrayOfJson,
),
]
->Dict.fromArray
->JSON.Encode.object
]->getJsonFromArrayOfJson
}

let toCamelCase = str => {
Expand Down Expand Up @@ -387,8 +386,7 @@ let rec transformKeys = (json: JSON.t, to: case) => {
}
x
})
->Dict.fromArray
->JSON.Encode.object
->getJsonFromArrayOfJson
}

let getClientCountry = clientTimeZone => {
Expand Down Expand Up @@ -703,7 +701,7 @@ let handlePostMessageEvents = (
("elementType", "payment"->JSON.Encode.string),
("complete", complete->JSON.Encode.bool),
("empty", empty->JSON.Encode.bool),
("value", [("type", paymentType->JSON.Encode.string)]->Dict.fromArray->JSON.Encode.object),
("value", [("type", paymentType->JSON.Encode.string)]->getJsonFromArrayOfJson),
])
}

Expand Down Expand Up @@ -1023,8 +1021,7 @@ let mergeTwoFlattenedJsonDicts = (dict1, dict2) => {
dict1
->Dict.toArray
->Array.concat(dict2->Dict.toArray)
->Dict.fromArray
->JSON.Encode.object
->getJsonFromArrayOfJson
->unflattenObject
}

Expand Down

0 comments on commit 24ca6ff

Please sign in to comment.