Monthly Archives: December 2015

Converting JSON Time Format in SharePoint Document Library Metadata


The SharePoint farm has a Document Library and a List which are linked for some requirements, while querying information we received some data which are not in proper format. Challenge is to split, remove characters and count the total which is little tedious

Example- The Field3 in CSV yields [“\/Date(1444995273796)\/”,”\/Date(1444996968515)\/”]

It’s a JSON format and the time format is EPOCH (UNIX format) – With Reference to the link MSDN My advice to customer was to use below code snippet to break the mystery!

To get the count: (Unfortunately, this is what customer need!) – No Fun in it because this kills the actual flavor of SharePoint development and data.

(@"
["\/Date(1444995273796)\/","\/Date(1444996968515)\/"]
"@ | ConvertFrom-Json).Count

#Output
#2

The reason for the SPContext Code by developer is unknown. So here comes the ConvertFrom-JSON power in Windows PowerShell Version 3+ 🙂 🙂 🙂

To get the information about the data in JSON: [We will deep dive in Part 2 of this Blog]

@"
["\/Date(1444995273796)\/","\/Date(1444996968515)\/"]
"@ | ConvertFrom-Json

#Output

#Friday, October 16, 2015 11:34:33 AM
#Friday, October 16, 2015 12:02:48 PM

The file which is generated as report is done using C# and CSOM – So, in next blog post (Part 2) we will cover Binary Module using C# Class Library, PowerShell Module, String Manipulation and Data consolidation.

Enjoy PowerShell !