justinwoo / purescript-simple-json

A simple Purescript JSON library that uses types automatically

Home Page:http://purescript-simple-json.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to handle arbitrary String Maps/JSON

i-am-the-slime opened this issue · comments

I'm in a server setting. I find myself needing to route through some dynamic parts of a 3.6MB JSON response to the caller. So something like a field attributes :: Array JsonValue. Can I do this with simple-json?

I don't know what you're trying to do or how you'd accomplish this in JS normally. If the JSON values are individual values per line, then you will want to split up your input by lines.

I mean some JSON like this:

{  
  "known_field": 4,
  "known_field_2": "bla",
  "additional_dynamic_attributes": {
    "unknown_attribute_1": { "key": "value"},
    "unknown_attribute_2": 5,
    ... more of these
  }
}

Imagine I get something like this as a response from an API call. I don't care about these attributes, I just want to proxy them to whoever called my service.

Do you want to type that as Foreign.Object.Object Foreign and pass it through? Do you want to call parseJSON to only parse it from a String to Foreign to pass through?

Ah! I think Foreign.Object.Object Foreign is probably the solution I was looking for!