Modify json result and send it back, VBA

I have a result from an API and the way this API work, to modify even only one field, I have to send back all fields.
What I whant is to modify the fields I whant and send back the info to the API.
I know I can use string function to do that, but I whant to know if theres a library or sommething more simple that I can use to just change some part of the result.
Here what I receive from the API:

{
  "id": "a05b0aa4-d622-4bda-8a0d-0b287bc43c7a",
  "idStatus": null,
  "isUser": false,
  "company": null,
  "department": null,
  "companyID": "",
  "contactType": "Contact",
  "firstName": "test302",
  "lastName": "test2",
  "lastResults": null,
  "messengerID": null,
  "middleName": null,
  "nameSuffix": null,
  "namePrefix": null,
  "fullName": "test302 test2",
  "referredBy": null,
  "salutation": "test302",
  "jobTitle": null,
  "emailAddress": "dfgfdg£g.com",
  }

Open in new window

I need to send back the exact same thing but with some change. Exemple, I would like to change the "firstname" to something else.
Gontran HarveyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike in ITIT System AdministratorCommented:
I don't think there are any built-in libraries which would handle this other than the functions that you already mentioned. You might be able to find some 3rd party libraries that might help.
0
Gontran HarveyAuthor Commented:
I did not want to go there, but if I have to I will!! thanks.
0
Gontran HarveyAuthor Commented:
Here the function I created for that.

Public Function strNewFieldValue(strAPI_String As String, strField As String, strNewValue As String) As String
    Dim lPosition As Long
    Dim lPos_2_Point As Long
    Dim lPos_Virgule As Long
    Dim lNb_Caractere As Long
    Dim strActualFieldData As String
    Dim strLeftPart As String
    Dim strRightPart As String
    
    
    'cette function remplace la valeur du champs par une autre valeur
    'La strNewValue est une valeur text ou marquer null si ont veut une valeur null dans le champs
    'La fonction s'occupe de mettre les extra double guillemet et les enlever pourla valeur null
    
    If strNewValue <> "null" Then
        strNewValue = """" & strNewValue & """"
    End If
    
    strNewValue = " " & strNewValue & ","
    
    lPosition = InStr(1, strAPI_String, "" & strField & "")
    If lPosition <> 0 Then
        lPos_2_Point = InStr(lPosition, strAPI_String, ":")
        lPos_Virgule = InStr(lPosition, strAPI_String, ",")
        lNb_Caractere = lPos_Virgule - lPos_2_Point
        
        strActualFieldData = Mid(strHTML, lPos_2_Point + 2, lNb_Caractere - 2)
        
        strLeftPart = Left(strAPI_String, lPos_2_Point)
        
        strRightPart = Right(strAPI_String, Len(strAPI_String) - lPos_Virgule)
        
        strNewFieldValue = strLeftPart & strNewValue & strRightPart
        
        Debug.Print strNewFieldValue
    Else ' ce champs ne semble pas existé
        strNewFieldValue = ""
    End If
    
End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Mike in ITIT System AdministratorCommented:
Does the code you wrote solve the problem?

If it doesn't are there any errors or parts that don't work the way you would like them to?
0
Gontran HarveyAuthor Commented:
yes work perfectly!!
thanks
0
Gontran HarveyAuthor Commented:
Because there is no real solution exept the code I just posted
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.