# Http outcall response JSON processing in Motoko

**URL:** https://forum.dfinity.org/t/http-outcall-response-json-processing-in-motoko/15977
**Category:** Language Support
**Tags:** Motoko, Education
**Created:** [October 19, 2022, 9:47am UTC](https://forum.dfinity.org/t/http-outcall-response-json-processing-in-motoko/15977 "2022-10-19T09:47:06Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![Kyan](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/kyan/32/6488_2.png) [@Kyan](https://forum.dfinity.org/u/Kyan)
#### Post date: [October 19, 2022, 8:24pm UTC](https://forum.dfinity.org/t/http-outcall-response-json-processing-in-motoko/15977/3 "2022-10-19T20:24:45Z")

</div>

I have encountered the same problem without having found a ready-made solution. So I wrote a parser that allows me to recover the value of a json object. It works in my use case but you can use it as inspiration :

```auto
public func parseValue(json : Text, obj : Text) : async Text {
        var r : Text = "";
        let b : Buffer.Buffer<Text> = Buffer.Buffer(1);
        for (e in Text.split(json, #text "[")) {
            if (Text.contains(e, #text obj)) {
                for (o : Text in Text.split(e, #text "{")) {
                    var j : Text = Text.replace(o, #text "}", "");
                    j := Text.replace(j, #text "]", "");
                    if (Text.endsWith(j, #text ",")) {
                        j := Text.trimEnd(j, #text ",");
                    };
                    for (f : Text in Text.split(j, #text ",")) {
                        if (Text.contains(f, #text obj)) {
                            for (t : Text in Text.split(f, #text ":")) {
                                switch (Text.contains(t, #text obj)) {
                                    case (false) {
                                        b.add(Text.replace(t, #text "\"", ""));
                                    };
                                    case (true) {};
                                };
                            };
                        };
                    };
                };
            };
        };
        r := b.get(b.size() - 1);
        return r;
    };

```

---

_[View the full topic](https://forum.dfinity.org/t/http-outcall-response-json-processing-in-motoko/15977)._
