How to split a JSON object into an array

I’ve got a JSON object that looks like this

Key1      = Value1
Key2      = Value2

This pattern continues x times, always

  • KeyName
  • Unknown length of whitespace
  • = character
  • Value
  • New line

If I JSON.Stringify I get

Key1      = Value1\nKey2     = Value2\nKey3      = Value3\n

How can I get an object along the lines of

{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}

84 thoughts on “How to split a JSON object into an array”

Leave a Comment