0

I am using the nlohmann::Json to converting the map<string,string> to stringJson in c++ side. using that stringjson, I have passed entire Json to C# side using PINVOKE. I am struggling to parse the Json when folder is having multiple data. For example :

recFace_callback_Json :
"{
  \"C:\\\\Images\\\\Cel\\\\05.jpg\":\" [{\\\"acc\\\":1.0,\\\"he\\\":146]\",

   \"C:\\\\Images\\\\Cel\\\\06.jpg\":\"[{\\\"acc\\\":1.0,\\\"he\\\":272}, 
     {\\\"acc\\\":2.0,\\\"he\\\":472}]\"
 }"

Any one ? How to handle all data

ASh
  • 34,632
  • 9
  • 60
  • 82
Satyam Mishra
  • 333
  • 3
  • 10
  • C# also has similar libraries for parsing Json -- actually, I think .Net has it built in. Are you asking what those libraries are, or are you asking how to parse the data yourself? – ChrisMM Mar 30 '21 at 11:45
  • I wanted to parse data by myself, so one thing I wanted to add, when I use Json.Name , it is giving the file path and Json.Value is giving me the value ([{\\\"acc\\\":1.0,\\\"he\\\":146]). So is it good to iterate those and assign it to list of Dictonary.? – Satyam Mishra Mar 30 '21 at 12:55
  • 1) The JSON shown in your question is malformed, upload it to https://jsonlint.com/ and you will get errors. Is that your real JSON? If so, you should fix it not to be malformed. 2) What exactly is your problem? How to deserialize JSON in c#? If so see [*How do I turn a C# object into a JSON string in .NET?*](https://stackoverflow.com/a/19137100/3744182). If you could [edit] your question to show a [mcve] with your actual JSON showing where you are stuck, it's more likely we can help. – dbc Mar 30 '21 at 13:28
  • I.e. are you looking for help with [tag:c++] [tag:nlohmann-json] or [tag:c#] [tag:json.net]? Depending on your needs a different person will likely know the answer. – dbc Mar 30 '21 at 13:31
  • Thanks @dbc , I totally appreciate for all the links provided. 1. what I have mentioned is just a json string not Json object. I solved this one. Still thanks a lot for all the links :) – Satyam Mishra Mar 31 '21 at 06:57
  • Why i am gettting json like this because , I was getting result in map which I converted to json string using nlohman::convertMaptoJson. then only I was getting this type of malformed – Satyam Mishra Mar 31 '21 at 06:58

0 Answers0