Lots of headache here, how do I deserialize JSON like the one in the image? I'd usually see things like {"Word" : "Fish","Definition" : "It is an animal", etc} but the one I have found that is the closest thing to what I am looking for does not specify the value type, hence I can't really deserialize it with case classes. I'm sorry that I'd really prefer a clear explanation, I'm bad at this.
I'm really looking forward to an answer, thank you for reading.
It would appear that you are trying to parse an actual dictionary that is in a psuedo json format but looks more like a key value pair surrounded by braces. If I were going to solve a problem like this I would use basic string parsing. To properly deserialize JSON the JSON has to be valid and you must be able to represent the json as a case class. The text in the image can't be represented as a case class because non of the elements appear more than once.
Here is a working example of how I would solve this problem in scala.
Steps:
Test: define the string as a variable
Test2: remove text that isn't needed using the replace function chained several times
Test3: Split the string into several arrays based on the commas
Test4: Iterate through the array and split smaller strings on the :
Test5: Iterate through the array of arrays and make key value pairs and then convert into a map.
Test5 is now a scala map representation of the type of document shown in the picture and you can access values based on keys.
While this will work it would be slow for a large document and it might be better to represent this as a properly defined JSON document that can be serialized and deserialized using standard methods. A properly formatted json document could look like.