ParseJson
import { pipe } from "fp-ts/lib/pipeable";
import * as E from "fp-ts/lib/Either";
import * as A from "fp-ts/lib/Apply";
const dataToBeParsed = JSON.stringify({ firstJson: true });
pipe(
E.parseJSON(dataToBeParsed, E.toError),
E.fold(
e => console.log(e),
data => console.log(data)
)
);
// {"firstJson":true}import { pipe } from "fp-ts/lib/pipeable";
import * as E from "fp-ts/lib/Either";
import * as A from "fp-ts/lib/Apply";
const dataToBeParsed = JSON.stringify({ firstJson: true });
const secondDataToBeParsed = JSON.stringify({
thisIsTheSecondJson: "Yes it is"
});
pipe(
E.parseJSON(dataToBeParsed, E.toError),
E.chain(one =>
pipe(
E.parseJSON(secondDataToBeParsed, E.toError),
E.map(two => [one, two])
)
),
E.fold(
e => console.log(e),
data => console.log(data)
)
);
// [{"firstJson":true},{"thisIsTheSecondJson":"Yes it is"}]Last updated